Quantcast
Channel: SQL Server Data Access forum
Viewing all 4164 articles
Browse latest View live

OS HDD Partition is Toast - I have access to physical SQL Data Files - How do I get databases into new SQL Install?

$
0
0

Our Server 2008 R2 OS partition is toast.  I have plugged the drive into a regular PC and can see all the physical SQL DATA:

Local disk F: Program Files \ Microsoft SQL Server \ MSSQL10.MSSQLSERVER \ MSSQL \ DATA \ datafiles & transaction log files

I am setting up a new server and reinstalling SQL 2008 R2 on it.    How do I get all those databases moved to / reinstalled on the new server?


Arthur J Wohlers, Ph.D.


Import MS Access 2013 tables into SQL Server 2012

$
0
0

Hi there,

Is there a step by step example somewhere showing how to import an MS Access 2013 table into SQL Server 2012?

I have read the existing posts and don't see a definitive answer.

I have installed MS Access 2010 engine, first 32 bit then 64 bit.

I have installed the MS Access 2013 runtime on my server.

I use the Office 2015 Access Database Engine OLE DB Provider.

I get the error:

Error 0xc0202009: Source - APEntries [1]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E37.


Error 0xc02020e8: Source - APEntries [1]: Opening a rowset for "`TableName`" failed. Check that the object exists in the database.

The post regarding the above errors doesn't resolve the issue.

I have full administrative permissions on the server.

What is the trick to making this work?

Thanks,

Ric


Ric Miller

VB Connect String for AttachDbFilename

$
0
0

So the context is: I have an app I inherited that was using Access. Time to upsize (yes, have to) to SQLExpress because of the file size limits of Access*. I can do everything via the server interaction, but it's about 50-300% slower than via the access DB. 

Because my app serves as the server for all the clients, only one user is ever connecting to the DB. I was hoping that a file-level connection would help with the slow speed I was seeing via the standard server connection. But so far I can't figure out how to connect any other way. The connect string that works via treating it as a 'real' server is: "Driver={SQL Server};Server=.\sqlexpress;Database=database;Trusted_Connection=yes;"

I thought I'd be able to use a string like this to connect to the .mdf file directly: "Driver={SQL Server};Server=.\sqlexpress;AttachDbFilename=|DataDirectory|database.mdf;Database=database;Trusted_Connection=yes;"

I've tried dozens of variations on this theme and I either get (as with this string) errors like "Database <path> already exists. Choose a different database name." or any number of other problems. Tried changing form server= to data source=, tried many different authentication methods, &c. 

How should I be connecting from a Visual Basic connection if I want a more direct connection than client/server?

*This is just how it is: one table is 98% of our DB size and it uses (unfortunately) memo/nvarchar(max) fields extensively.

OLEDB provider error..

$
0
0

Can someone hemp me to resolve the following issue? 

Gets following 3 errors.

(2 row(s) affected)
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Cannot update. Database or object is read-only.".
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider indicates that the user did not have the permission to perform the operation.
Msg 7343, Level 16, State 2, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" could not INSERT INTO table "[Microsoft.ACE.OLEDB.12.0]". 

Transaction isolation level in ADO.NET

$
0
0

Hi

I was reading in BOL that a sql connection will maintain the last isolation level that was set using a SET TRANSACTION ISOLATION LEVEL, even when it is returned back to the connection pool.

Does anyone know if in ADO.NET, when I call Connection.BeginTransaction and specify the IsolationLevel as, say, SNAPSHOT, when the transaction is committed, will it affect my connection once it has returned to the pool or will its next use use the default for the database?

Thanks for your help

Graham

Convert number to date

$
0
0

I want convert the numbers to print out MON- YY or MON-YYYY  - like 201104 I want to convert to APR-2011 or APR-11.

BCP utility permission / connection

$
0
0

BCP (in/out/queryout) functions very well on local / test machine - both from the cmd prompt and the browser (odbc with IIS and vbscript).

On the production machine (sql 2008 web edition), the same commands work perfect only IF I connect with remote desktop and use cmd (connecting as admin) ... But the browser returns error or fails to perform without returning an error message.

I guess the problem is related to user and permissions (browser vs admin using cmd). There is no problem with folder permissions.

Is it permissions on table/s, the bcp or ...? Which permissions / where should be adjusted?

Thanks,
Ken

SQL Parameters: Add vs. AddWithValue

$
0
0

I'm in the process of designing an application (Visual C# 2012) that will be working with a SQL database, and have been using parameters in my queries.

My question is if there is any advantages/disadvantages to using AddWithValue over Adding the paramater and then specifying the value and type in a separate instruction (in the C# code)?

I've read a few places that sometimes with AddWithValue, either the .Net framework or SQL doesn't always select the appropriate datatype for the parameter and can cause errors.  But on the other hand, using AddWithValue can reduce the number of lines of code you have to write (some of my queries might have 10+ parameters, which is small compared to a database for a multi-site Enterprise database system) and thus make your code faster (hopefully).

Opinions as to whether to use Add + extra statements, or just use AddWithValue?


BCP utility permission / connection problem

$
0
0

BCP (in/out/queryout) functions very well on local / test machine - both from the cmd prompt and the browser (odbc with IIS and vbscript).

On the production machine (sql 2008 web edition), the same commands work perfect only IF I use cmd (connecting as admin) ... But the browser returns error or fails to perform without returning an error message.

I guess the problem is related to user and permissions (browser vs admin using cmd). There is no problem with folder permissions.

Command sample is:

bcp "select * from MyTable where id < 600" queryout "C:\MyFolder\MyFile.txt" -c -S"MyServer\Instance" -U"UserName" -P"MyPassword"

And the error message is either "sqlstate 28000" which is "Invalid authorization specification" or ... no error message at all and no result at all (appears that command is totally ignored).

Is it permissions on sql table/s, the bcp.exe or ...? Which permissions / where should be adjusted?

Thanks,
Ken




List of SQL server Agent jobs for a SSIS package

$
0
0

Hello everyone,

Can you please help me in trying to list all the jobs that have a particular ssis jobs. I saw that all the jobs and jobs steps with the query:

SELECT

   Srv.srvname AS ServerName,

   Job.name AS JobName,

   JStep.step_id,

   JStep.step_name AS StepName,

   JStep.command,

   Job.enabled

FROM   dbo.sysjobs Job

JOIN   dbo.sysjobsteps JStep

   ON  JStep.job_id = Job.job_id

JOIN   MASTER.dbo.sysservers Srv

   ON  Srv.srvid = Job.originating_server_id

--WHERE  JStep.subsystem='SSIS'

WHERE    JStep.step_name = <Job_step_name>

And also found sysssispackages table for all ssis packages. But I am not sure how to link the package to job. Please help me.

Thanks in advance.


Unable to connect to the server: [DBNMPNTW}Connection broken

$
0
0

I'm using SmartPlant 3D Design. The application works before but suddenly when I'm trying to modify the site database Location a pop-up message appears 

Unable to connect to the server: [DBNMPNTW}Connection broken

I'm sure im not modifying any of the server's settings and also on its configuration on my client pc.

I noticed this error after installation of Visual Basic 6.

Badly needed help.

You can email me at drfsison_12@yahoo.com for possible solutions.

Thank you.

Inserting data into table through linked server

$
0
0

Hi

I am trying to insert data from a remote database into my database using linked server.

Below is the syntax that I am using

set XACT_ABORT on
INSERT INTO MyTable
EXEC [172.xx.xx.xxx].MyDatabase.dbo.[MyStoredProc] '2014-10-20','2014-10-26'  

When I execute the SP (EXEC [172.xx.xx.xxx].MyDatabase.dbo.[MyStoredProc] '2014-10-20','2014-10-26'   ) I get the result.

but when I try inserting the data into a table using the above code I get the following error

OLE DB provider "SQLNCLI11" for linked server "172.xx.xx.xxx" returned message "No transaction is active.".
Msg 7391, Level 16, State 2, Line 59
The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "172.xx.xx.xxx" was unable to begin a distributed transaction.

I tried solutions given on

http://stackoverflow.com/questions/7473508/unable-to-begin-a-distributed-transaction

but still i get the issue... I don't know whats wrong.

Lack of TCP keepalive parameter in Microsoft SQL Server ODBC Driver for Linux

$
0
0

Hello,

the problem in theaforementioned driver is the lack of TCP keepalive parameter that results in hanged threads because of closed connections on the SQL Server side, but not closed sockets on the client side. This could happen due to network-related problems.

The driver is used in mission critical 24/7 uptime application and due to hanged threads the application cannot continue it's work and it needs to be restarted.

This is observed in the latest version of the driver on RHEL 5.6.

If you need clarification please ask.

Does anybody know any workaround to this situation or a solution that I'm not aware of?

--

Thank you for your help,

luk.s


Transfering data from MSSQL to BW 7.31

$
0
0


I  manual (2D post) -  it is not full , we did everything step by step but when user send invoice (PUSH preview buttom in SQL STUDIO) to BW DTP REQUEST felt with error : SYSTEM_FAILURE with function RSB_API_OHS_3RDPARTY_NOTIFY and target system MSSAPBI (screenshot second post)

FOUnd code of this FM :

FUNCTION rsb_api_ohs_3rdparty_notify .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(OHDEST) TYPE RSOHDEST OPTIONAL
*" VALUE(REQUESTID) TYPE RSBREQUIDOUT OPTIONAL
*" VALUE(NUMB_OF_PACKETS) TYPE I OPTIONAL
*" VALUE(DBTABNAME) TYPE RSBTABNAME OPTIONAL
*" VALUE(DBRECORDS) TYPE SYTABIX OPTIONAL
*" VALUE(TIMESTAMP) TYPE RSBTIMESTAMP OPTIONAL
*" VALUE(REQUEST_GUID) TYPE RSREQUID OPTIONAL
*" EXPORTING
*" VALUE(RETURN) TYPE BAPIRET2
*" TABLES
*" PARAMETERS STRUCTURE BAPI6107PA OPTIONAL
*" EXCEPTIONS
*" COMMUNICATION_FAILURE
*" SYSTEM_FAILURE
*"----------------------------------------------------------------------

* must be implemented in the 3rd party system - !!!
ENDFUNCTION.

Found doc (second post)   - p.222 there is description of this function ( rsb_api_ohs_3rdparty_notify ) Our SQL consultant says it is old  functionality. Do U know how implement it by new version of SQL Server Management Studio 2012 ?




alpha numeric

$
0
0

Hello,

I have a primary key column with alpha numeric value. some value has 4 alpha and 5 numbers, some has 5 alpha and 4 numbers. I want to tag in a qry 5 alpha and 4 numbers to as "Major" and 4 alpha and 5 number as "minor" . Is there a way to tag it in a SQL query ?

Thank you,

Kashyap


bcp not working on Linux platform

$
0
0

Hi,

I am trying to import data into table using bcp.

I am running bcp command on a remote linux machine, I have already installed the native ODBC driver for MSSQL. I am able to connect to the SQL server using isql.

Linux firewall is turned off, iptables service is also stopped.

cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.2 (Santiago)

Below is the bcp command I am trying to execute:

/bcp darwinapp.dbo.[order] in /opt/results/SQLSERVER_FMT/order.csv -f /opt/results/SQLSERVER_FMT/order.fmt -S <SQL SERVER IP>\MSSQLSERVER1 -T -U <username> -P <password>

Error = [unixODBC][Microsoft][SQL Server Native Client 11.0]Login timeout expired
SQLState = 08001, NativeError = 10022
Error = [unixODBC][Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
SQLState = 08001, NativeError = 10022
Error = [unixODBC][Microsoft][SQL Server Native Client 11.0]TCP Provider: Error code 0x2726

Any help in this regard would be of great help.

Regards,

Deepak

Transport-level error ;

$
0
0

Hi I am detaching few databases from a sql instance from powershell, then we have a process that does a clone of the disks from another instance and restarts sql service. Then another process attaches all the databases(using invoke-sqlcmd) detached earlier and executes a stored proc. But when am executing the stored proc , i get this error..

Exception calling "Fill" with "1" argument(s): "A transport-level error has occurred when sending the request to the server. (provider:Shared Memory Provider, error: 0 - The pipe is being closed.)"

Code below to execute the sql commands. But i don't get this error when i run the command again , any way to clear the pool?

Thanks

 $lclSqlConn = New-Object System.Data.SqlClient.SqlConnection
    $lclSqlConn.ConnectionString = "$ConnStr"
    $lclSqlConn.Open() | out-null
    $lclSqlCmd = New-Object System.Data.SqlClient.SqlCommand 
    $lclSqlCmd.Connection = $lclSqlConn
    $lclSqlCmd.CommandText =  $Cmd
$lclSqlCmd.CommandTimeout=$QueryTimeout
    if ( $CmdType.ToUpper() -eq "SP") {
      $lclSqlCmd.CommandType = [System.Data.CommandType]'StoredProcedure'
    } else {
      $lclSqlCmd.CommandType = [System.Data.CommandType]'Text'
    }
    if (($CmdParam) -and ($CmdType -eq "SP")) {
      $CmdParam.split($Sep1) | Foreach-Object {  
     $pos = $_.IndexOf($Sep2)
$lclPar = @($_.Substring(0, $pos),$_.Substring($pos+$Sep2.length))
      $lclSqlCmd.Parameters.AddWithValue($lclPar[0],$lclPar[1]) | out-Null
 }
    }
    $lclSqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter 
    $lclSqlAdapter.SelectCommand = $lclSqlCmd 

    $lclDataSet = New-Object System.Data.DataSet 
    $lclSqlAdapter.Fill($lclDataSet) | Out-Null
    $lclSqlConn.Close()
return @{"ExitCode" = $true; "ExitMsg" = ""; "DataSet" = $lclDataSet; "ErrorType" = $null; "SQLErrNr" = $null; "SQLState" = $null}
  }
  catch [System.Data.SqlClient.SqlException] {
return @{"ExitCode" = $false; "ExitMsg" = $error[0].ToString(); "DataSet" = $null; "ErrorType" = "SQL"; "SQLErrNr" = $_.Exception.GetBaseException().Number; "SQLState" = $_.Exception.GetBaseException().State}
  }
  catch {
  return @{"ExitCode" = $false; "ExitMsg" = $error[0].ToString(); "DataSet" = $null; "ErrorType" = "APP"; "SQLErrNr" = $null; "SQLState" = $null}
  }

ResultSet.getMetaData().getColumn() increments row cursor position

$
0
0

Using the sqlserver 4.0 jdbc driver, a call to getMetaData() positions the cursor to the next row in the table so when resultSet.next() is called the row is already at row 2 which is incorrect. 

For example in :

       final int columnCount = resultSet.getMetaData().getColumnCount();
        while (resultSet.next()) {
            for (int i = 1; i <= columnCount; i++) {
                System.out.println(resultSet.getString(i));
            }
           
        }

the first call to resultSet.getString(i) is returning the first column of row 2, not row 1. Removing the call to resultSet.getMetaData().getColumnCount() ensures that the first call to resultSet.next() is correctly positioned at the first row in the table.

In fact, several calls to resultSet.getMetaData().getColumnCount(); before a resultSet.next() keeps incremeneting the row cursor. 

This doesn't happen with jdbc drivers of other database such as Oracle, Postgresl, and MySql


Application call to ODBC SQLSetEnvAttr function throw HY011 exception

$
0
0

Hi All,

      I try to use odbc driver manager in my .Net Application.first My .Net runtime is 3.5, odbc function calls(unmanaged functions are  imported to .Net application by dllimport attribute)can work well.but when .Net runtime is upgraded to 4.0,SetEnvAttr function calls

return SQL-ERROR and I call SQLGetDiagRec function  get this error information:Operation invalid at this time.sqlstate value is HY011.

below is my code fragment:

     
  [DllImport("odbc32.dll")]
        extern static short SQLSetEnvAttr(
            IntPtr envHandle,
            ushort attribute,
            IntPtr attrValue,
            int stringLength);

        [DllImport("odbc32.dll")]
        extern static short SQLAllocHandle(
            ushort HandleType,
            int InputHandle,
            out IntPtr OutputHandle);
try
            {
                rc = SQLAllocHandle(SQL_HANDLE_ENV, 0, out sql_env_handle);
                if ((rc != SQL_SUCCESS) && (rc != SQL_SUCCESS_WITH_INFO))
                {
                    throw new Exception("SQLAllocHandle: failed to allocate SQL_HANDLE_ENV");
                }
                rc = SQLSetEnvAttr(sql_env_handle, SQL_ATTR_ODBC_VERSION, (IntPtr)SQL_OV_ODBC3, 0);
                //if ((rc != SQL_SUCCESS) && (rc != SQL_SUCCESS_WITH_INFO))
                //{
                //    throw new Exception("SQLSetEnvAttr: failed to set SQL_ATTR_ODBC_VERSION");
                //}
                if((rc == SQL_SUCCESS_WITH_INFO)||(rc == SQL_ERROR))
                {
                    short i=1;
                    short rc2;
                    StringBuilder sqlstate=new StringBuilder();
                    int NativeErrorPtr=0;
                    StringBuilder MessageText=new StringBuilder();
                    short BufferLength=256;
                    short TextLengthPtr=0;
                    while ((rc2 = SQLGetDiagRec((short)SQL_HANDLE_ENV,sql_env_handle,i,sqlstate,
                        ref NativeErrorPtr,MessageText,BufferLength,ref TextLengthPtr))!= SQL_NO_DATA)
                        {
                        i++;
                    }
                }

my operation system is win7 64bit. Could someone help me? thanks

character encoding issue in sql server

$
0
0

Hi Team,

We have a table with more than 20 columns...In that we have some columns which will have data extracted from the Datawareshouse applicances and its one time load.

The problem is we have two columns which will may have same set of values from some records and for different set of records

the below values are the example for same set of records but the values are changed while importing into the sql server database..

2pk Etiquetas Navide‰as 3000-HG                                2pk Etiquetas Navideñas 3000-H                          

Is there anyway to change the first column values into the second column value ? 

By looking at the data we can say its the code page issue..(Character encoding issue)..but how to convert it?

Convertting(2pk Etiquetas Navide‰as 3000-HG)  to get   2pk Etiquetas Navideñas 3000-H   in the select query?

Viewing all 4164 articles
Browse latest View live