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

SQL MERGE syntax works with Win7 SP1 client but fails with earlier platforms

$
0
0
My native C++ client application creates the following SQL  and then uses a Command object to execute it against a SQL Server 2008 database target.  I am finding that the same SQL works fine on Win7 with SP1 or WinServer 2008R2 with SP1 but fails on earlier platforms with Recordset error 80040e14, IDispatch error #3092, description="Incorrect syntax near the keyword 'MERGE'".  
I'm aware of the issues caused by compiling under Win7 SP1 and have reverted to a version of my app which was compiled before SP1 and get the same error.  I'm wondering whether ADO pre-SP1 'understands' the MERGE syntax, or would welcome some advice on what the problem is.  I think my workaround is going to be something like creating a stored procedure and then executing it but the existing way is my preferred one.  Anyway, the SQL is:
MERGE pdata_7_PCYT AS target USING
(
Select
  pdata_PClookup.ProdCustID,
  qry.Period,
  qry.Yr,
  qry.[BaseQty], qry.[PromoQty], qry.[PromFlag], qry.[Qty], qry.[GSV], qry.[OffInPCGBP], qry.[OffInvPctGBP], qry.[TtOffInv], qry.[InvValue], qry.[RetrPPCGBP], qry.[RetroPctGBP], qry.[TotRetro], qry.[CSV], qry.[TrmDPPCGBP], qry.[TermsPctGBP], qry.[TermsTot], qry.[NSV], qry.[COG], qry.[NetMarg], qry.[CUMQty], qry.[CUM_GSV], qry.[CUMInvGBP], qry.[CUM_CSV], qry.[CUM_NSV], qry.[CUMMarg], qry.[BudTtQty], qry.[BudGSV], qry.[BudInvGBP], qry.[BudCSV], qry.[BudNSV], qry.[BudMarg]
From
  (Select
      pdata_Prod._parent,
      pdata_Cust.custcode,
      pdata_7_PCYT.Period,
      pdata_7_PCYT.Yr,
      SUM(pdata_7_PCYT.[BaseQty]) AS [BaseQty], SUM(pdata_7_PCYT.[PromoQty]) AS [PromoQty], SUM(pdata_7_PCYT.[PromFlag]) AS [PromFlag], SUM(pdata_7_PCYT.[Qty]) AS [Qty], SUM(pdata_7_PCYT.[GSV]) AS [GSV], SUM(pdata_7_PCYT.[OffInPCGBP]) AS [OffInPCGBP], SUM(pdata_7_PCYT.[OffInvPctGBP]) AS [OffInvPctGBP], SUM(pdata_7_PCYT.[TtOffInv]) AS [TtOffInv], SUM(pdata_7_PCYT.[InvValue]) AS [InvValue], SUM(pdata_7_PCYT.[RetrPPCGBP]) AS [RetrPPCGBP], SUM(pdata_7_PCYT.[RetroPctGBP]) AS [RetroPctGBP], SUM(pdata_7_PCYT.[TotRetro]) AS [TotRetro], SUM(pdata_7_PCYT.[CSV]) AS [CSV], SUM(pdata_7_PCYT.[TrmDPPCGBP]) AS [TrmDPPCGBP], SUM(pdata_7_PCYT.[TermsPctGBP]) AS [TermsPctGBP], SUM(pdata_7_PCYT.[TermsTot]) AS [TermsTot], SUM(pdata_7_PCYT.[NSV]) AS [NSV], SUM(pdata_7_PCYT.[COG]) AS [COG], SUM(pdata_7_PCYT.[NetMarg]) AS [NetMarg], SUM(pdata_7_PCYT.[CUMQty]) AS [CUMQty], SUM(pdata_7_PCYT.[CUM_GSV]) AS [CUM_GSV], SUM(pdata_7_PCYT.[CUMInvGBP]) AS [CUMInvGBP], SUM(pdata_7_PCYT.[CUM_CSV]) AS [CUM_CSV], SUM(pdata_7_PCYT.[CUM_NSV]) AS [CUM_NSV], SUM(pdata_7_PCYT.[CUMMarg]) AS [CUMMarg], SUM(pdata_7_PCYT.[BudTtQty]) AS [BudTtQty], SUM(pdata_7_PCYT.[BudGSV]) AS [BudGSV], SUM(pdata_7_PCYT.[BudInvGBP]) AS [BudInvGBP], SUM(pdata_7_PCYT.[BudCSV]) AS [BudCSV], SUM(pdata_7_PCYT.[BudNSV]) AS [BudNSV], SUM(pdata_7_PCYT.[BudMarg]) AS [BudMarg]
    From
      pdata_7_PCYT Inner Join
      pdata_PClookup On pdata_7_PCYT.ProdCustID = pdata_PClookup.ProdCustID
      Inner Join
      pdata_Cust On pdata_PClookup.CustCode = pdata_Cust.custcode Inner Join
      pdata_Prod On pdata_PClookup.ProdCode = pdata_Prod.prodcode
    Where
      pdata_Prod._level = 4 And
      pdata_Cust._level = 2
    Group By
      pdata_Prod._parent, pdata_Cust.custcode, pdata_7_PCYT.Period,
      pdata_7_PCYT.Yr
   ) qry Inner Join
  pdata_PClookup On qry._parent = pdata_PClookup.ProdCode And
    qry.custcode = pdata_PClookup.CustCode
 ) AS source
 ON source.ProdCustID=target.ProdCustID AND source.Period=target.Period AND source.Yr=target.Yr
 WHEN MATCHED THEN
 UPDATE SET [BaseQty]=source.[BaseQty], [PromoQty]=source.[PromoQty], [PromFlag]=source.[PromFlag], [Qty]=source.[Qty], [GSV]=source.[GSV], [OffInPCGBP]=source.[OffInPCGBP], [OffInvPctGBP]=source.[OffInvPctGBP], [TtOffInv]=source.[TtOffInv], [InvValue]=source.[InvValue], [RetrPPCGBP]=source.[RetrPPCGBP], [RetroPctGBP]=source.[RetroPctGBP], [TotRetro]=source.[TotRetro], [CSV]=source.[CSV], [TrmDPPCGBP]=source.[TrmDPPCGBP], [TermsPctGBP]=source.[TermsPctGBP], [TermsTot]=source.[TermsTot], [NSV]=source.[NSV], [COG]=source.[COG], [NetMarg]=source.[NetMarg], [CUMQty]=source.[CUMQty], [CUM_GSV]=source.[CUM_GSV], [CUMInvGBP]=source.[CUMInvGBP], [CUM_CSV]=source.[CUM_CSV], [CUM_NSV]=source.[CUM_NSV], [CUMMarg]=source.[CUMMarg], [BudTtQty]=source.[BudTtQty], [BudGSV]=source.[BudGSV], [BudInvGBP]=source.[BudInvGBP], [BudCSV]=source.[BudCSV], [BudNSV]=source.[BudNSV], [BudMarg]=source.[BudMarg]
 WHEN NOT MATCHED THEN
 INSERT (ProdCustID, Period, Yr, [BaseQty], [PromoQty], [PromFlag], [Qty], [GSV], [OffInPCGBP], [OffInvPctGBP], [TtOffInv], [InvValue], [RetrPPCGBP], [RetroPctGBP], [TotRetro], [CSV], [TrmDPPCGBP], [TermsPctGBP], [TermsTot], [NSV], [COG], [NetMarg], [CUMQty], [CUM_GSV], [CUMInvGBP], [CUM_CSV], [CUM_NSV], [CUMMarg], [BudTtQty], [BudGSV], [BudInvGBP], [BudCSV], [BudNSV], [BudMarg])
 VALUES (source.ProdCustID, source.Period, source.Yr, source.[BaseQty], source.[PromoQty], source.[PromFlag], source.[Qty], source.[GSV], source.[OffInPCGBP], source.[OffInvPctGBP], source.[TtOffInv], source.[InvValue], source.[RetrPPCGBP], source.[RetroPctGBP], source.[TotRetro], source.[CSV], source.[TrmDPPCGBP], source.[TermsPctGBP], source.[TermsTot], source.[NSV], source.[COG], source.[NetMarg], source.[CUMQty], source.[CUM_GSV], source.[CUMInvGBP], source.[CUM_CSV], source.[CUM_NSV], source.[CUMMarg], source.[BudTtQty], source.[BudGSV], source.[BudInvGBP], source.[BudCSV], source.[BudNSV], source.[BudMarg]);

Sorry it is so ugly!  :-(
Thanks for (hopefully) some insights!
Pete

Creator of the Web Update Wizard... add update over the web to your app with a single line of code!


IT Professional

$
0
0

We have SQL server stored procedures running on SQL 2005 and access Oracle data through linked server using Oracle OLE DB provider. The application with the Oracle 11g has an upgrade recently. After the application is upgraded, now the performance of Stored procedures with the Oracle linked server is downgraded. The oracle db is under same version (11g).

 I’m wondering, other than using OPENQUERY, is there other alternative way to optimize the performance.

Thanks for your help!

How to set the account language (valid only for the session) in the connection string of the Sql Native Client provider

$
0
0

Hello,

I have a simple application that executes some queries in a SQL Server 2005 database using SNC SQL Native Client (OLEDB) provider.

The problem is that the date format used by the application is english (mm-dd-yyyy), but the account the application uses to log to the database is registered in SQL Server with Italian language.

The result is that, when in the application I set a range of dates (for example to extract the orders from 01 Jan 2013 to 31 May 2013), the classic error of data type conversion raises.

I should simply change the account language from italian to english using SQL Server Management, but the SQL Server instance contains other databases (and the account italian language setting could be important for them), so I have tried to set the account language directly in the string connection of the application ini file (so the account english language setting should be valid only for that session):

[DataBase]
DBMS=SNC SQL Native Client(OLE DB)
ServerName=SERVER\SQLEXPRESS
LogId=test
LogPassword=test
DBParm="Database='Orders',Language='us_english'"

but I have realized that it has no effect (the same conversion data error still raises).

Is the syntax I have used in the string connection not correct?

If it can be useful (even if I think the connection string syntax should be independent from this), the application is realized with Power Builder 12.5 (that supports SQL Native Client 9.0 and 10.0: I have tried both of them without success), and the SQL Server version is Microsoft SQL Server Express Edition 9.00.2047.00 (the 2005 version)

Thank you for the attention

string or binary would be truncated when inserting specific values

$
0
0

I am getting this error whenever I try to insert the integer 2 using c# to call a stored procedure

selectCommand.Parameters.AddWithValue("@modeloid", dbcs.ModeloID); // when dbcs.modeloid is 2 I get this message I debugged the code to check the value and all goes as expected when I pass 1 works fines 3 also and etc.

IMultipleResults::GetResult doesn't return DB_E_ERRORSINCOMMAND

$
0
0

I use ICommandText::Execute with IMultipleResults to execute a SELECT statement with an invalid column name. It returns DB_S_OK instead of DB_E_ERRORSINCOMMAND. And the IMultipleResults::GetResult returns DB_S_NORESULT.

Please let me know that whether any properties can suppress the return error value?

I use the following MARS properties,

    DBPROP rgPropMARS;

    rgPropMARS.dwPropertyID            = SSPROP_INIT_MARSCONNECTION;
    rgPropMARS.dwOptions            = DBPROPOPTIONS_REQUIRED;
    rgPropMARS.dwStatus                = DBPROPSTATUS_OK;
    rgPropMARS.colid                = DB_NULLID;
    V_VT(&(rgPropMARS.vValue))        = VT_BOOL;
    V_BOOL(&(rgPropMARS.vValue))    = VARIANT_TRUE;

    // Create the structure containing the properties.
    DBPROPSET PropSet;
    PropSet.rgProperties            = &rgPropMARS;
    PropSet.cProperties                = 1;
    PropSet.guidPropertySet            = DBPROPSET_SQLSERVERDBINIT;

Excel cell formatting while exporting data from sql server to Excel

$
0
0

Hi,

I am exporting data from sql server 2008 to excel using

Declare @sqlquery nvarchar(max)

SET @sqlquery='INSERT INTO OPENROWSET(''Microsoft.ACE.OLEDB.12.0'','''+'Excel 12.0;Database='+@filepath +';' + ''' ,

  ''SELECT * FROM [Sheet1$]'') ' + @query

EXEC sp_executesql @sqlquery
 
@filepath is where the file is kept with headers on which the sql server writes.

Now when I export the file.There are small green arrows in cells having numbers saying "The  number in the cell is formatted in text or preceded by an apostrophe." How can I make sql server 2008 to post numbers in number format in excel file.

Also, the numbers which are more than 7 digits like 1888120.26 get posted as 1.88812e+006.

Please tell me how to solve these two queries.


Stored procedure with no-rows-affected UPDATE causes SQLExecute to return SQL_NO_DATA in ODBC SQLNCLI

$
0
0

When using ODBC invoke a stored procedure, if the first statement in the procedure performs an UPDATE that affects zero rows, the "SQL Server Native Client 11.0" ODBC driver returns SQL_NO_DATA from SQLExecute. 

I do not see this behavior when using the original "SQL Server" ODBC driver.

Is this correct behavior? It doesn't seem to be. The ODBC documentation says that SQL_NO_DATA should returned from a 3.x driver to a 3.x client when SQLExecute "executes a searched update, insert, or delete statement that does not affect any rows at the data source".

For reference:
* Windows Server 2008 R2, (version 6.1 build 7601 SP1) 64-bit

* Drivers:

SQL Server 6.01.7601.1751 (11/20/2010)

SQL Server Native Client 11.0 2011.110.2100.60 (2/11/2012)

Unable to see databases sometimes after reboot -- SQL server 2012

$
0
0

Hello All,
I am currently trying to configure an ODBC connection to a database instance hosted on SQL server 2012 from Windows server 2008 R2.

I am using the the ODBC32AD.exe and when I get to the menu "which SQL server do you want to connect to" dropdown and select the intended sql server it only displays the FIMService and the master,model,smdb and tempdb.

When I reboot the server a couple of times then it displays all the db instances.

Is anybody facing this issue ? Please advice.


User context SQL conenction

$
0
0

Hi,

I am using ADO in C++ code to connec to SQL server. Based on user configuration, I use windows authentication or SQL authentication. I have win32 service running in Local System account which does the SQL connection etc operations.  I am using following connection string to connect :"Provider=SQLOLEDB;Server=SQLServerMachine;Initial Catalog=master;Trusted_Connection=YES";

I am impersonating the current thread with user credentials. (LogonUser / SetThreadTokan etc)
In ADODB::Open(), supplied the user name and password.

The problem is that SQL connection always happens using NT AUTHORITY\SYSTEM  account. verified using SQL profiler. I tried to provide user Id and password in connection string but still it does not use the provided user credentials. 

How can I make the SQL connection using the user supplied credentials and not in process context ?

Please guide.

regards.


SQL Linked Server to Informix connests but

$
0
0

Hi,

I have created a linked server in SQL2008 which tests fine but when I use it e.g: -

select*fromOpenquery(Sentinel,'Select * from Customer'

I get the following error: -

Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "Ifxoledbc" for linked server "Sentinel" reported an error. The provider did not give any information about the error.

Msg 7330, Level 16, State 2, Line 1

Cannot fetch a row from OLE DB provider "Ifxoledbc" for linked server "Sentinel".

OLEDB failed to login with SQL Server alias

$
0
0

I am not sure if it's a permission issue. when creating an OLEDB connection to sql server, it failed when using the alias but works fine with the instance name e.g someSQLServer\InstanceName. the weird thing is that it works the integration environment with the alias name but not the dev box (both environment are win2k3 server), in the dev box, it only works with the instance name. 

does anyone has any insight on this? and I don't it's the 32 bit 64 it issue mentioned here

http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/c701d510-90e5-4dd0-b14f-ca1d694d6615



Kevin

Will a read only query in Excel lock the records in MS SQL Server 2005 database?

$
0
0

Hello,

We have an ERP system from Lawson running on Windows Server 2003 and the backend database is MS SQL Server 2005. Occasionally we will experience the program dump in ERP system due to the database lock on records cannot be obtained.

The technical support from our ERP software supplier said this is caused by the outside database call which locked the records in the database. Specificly they mentioned the query from Excel - "If you use Microsoft Office, we often see MS Excel being used to pull data directly from M3. By default Office requests a full, exclusive lock on the tables and cause this kind of problem.".

We do have a lot of queries running from Excel, but all of them are with 'Select' statement only. We have no query in Excel will update the database, all of our query in Excel are read only from the database.

Is the statement of "By default Office requests a full, exclusive lock on the tables" ture? Expecailly on a read only query? By common sense a read only query should not lock the backend table.

In case of in fact Excel does lock the records for a read only query, if there any parameters / register key entries we can change so that it will not lock the table for read only query.

Thank you for your help.

Sql server-how to schedule jobs to dependent on each other

$
0
0
Sql server-how to schedule jobs to dependent on each other by job agent ??

JDBC FIPS Compliant Mode connection

$
0
0

I'm working on an application that requires FIPS 140 compliance mode for TLS connections, following the directions from http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/FIPS.html, which work for other TLS connections.  It seems as if the JDBC driver is using a different TrustManager than the default SunJSSE implementation. The following code works when the line new com.sun.net.ssl.internal.ssl.Provider(provider); is commented out, but otherwise produces the error listed below.  Is there a way to enable FIPS 140 compliant connections using the SQL Server JDBC driver?

public static void main(String[] args) throws Exception { Provider provider = new com.rsa.jsafe.provider.JsafeJCE(); Security.addProvider(provider); //Required to put TLS connections into FIPS 140 mode
//http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/FIPS.html new com.sun.net.ssl.internal.ssl.Provider(provider); Connection conn = null; Statement stmt = null; ResultSet res = null; try { String hostname = "server.example.com"; String connectionURL = "jdbc:sqlserver://"+hostname+":1433;integratedSecurity=true;database=ozone"; connectionURL += ";encrypt=true;trustServerCertificate=false"; connectionURL += ";trustStore=c:/cacerts;trustStorePassword=changeit"; System.out.println(connectionURL); Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); conn = DriverManager.getConnection(connectionURL); stmt = conn.createStatement(); res = stmt.executeQuery("select @@Version"); if (res.next()) { System.out.println(res.getString(1)); } } finally { if (res!=null) { try { res.close(); } catch (SQLException sqlEx) {}} if (stmt!=null) { try { stmt.close(); } catch (SQLException sqlEx) {}} if (conn!=null) { try { conn.close(); } catch (SQLException sqlEx) {}} } }


I receive an error this error:

Jun 6, 2013 4:01:44 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
INFO: java.security path: C:\Program Files\Java\jdk1.6.0_45\jre\lib\security
Security providers: [SUN version 1.6, SunRsaSign version 1.5, SunJSSE version 1.6, SunJCE version 1.6, SunJGSS version 1.0, SunSASL version 1.5, XMLDSig version 1.0, SunPCSC version 1.6, SunMSCAPI version 1.6, JsafeJCE version 6.001]
SSLContext provider info: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
SSLContext provider services:
[SunJSSE: KeyFactory.RSA -> sun.security.rsa.RSAKeyFactory
  aliases: [1.2.840.113549.1.1, OID.1.2.840.113549.1.1]
, SunJSSE: KeyPairGenerator.RSA -> sun.security.rsa.RSAKeyPairGenerator
  aliases: [1.2.840.113549.1.1, OID.1.2.840.113549.1.1]
, SunJSSE: Signature.MD2withRSA -> sun.security.rsa.RSASignature$MD2withRSA
  aliases: [1.2.840.113549.1.1.2, OID.1.2.840.113549.1.1.2]
, SunJSSE: Signature.MD5withRSA -> sun.security.rsa.RSASignature$MD5withRSA
  aliases: [1.2.840.113549.1.1.4, OID.1.2.840.113549.1.1.4]
, SunJSSE: Signature.SHA1withRSA -> sun.security.rsa.RSASignature$SHA1withRSA
  aliases: [1.2.840.113549.1.1.5, OID.1.2.840.113549.1.1.5, 1.3.14.3.2.29, OID.1.3.14.3.2.29]
, SunJSSE: Signature.MD5andSHA1withRSA -> com.sun.net.ssl.internal.ssl.RSASignature
, SunJSSE: KeyManagerFactory.SunX509 -> com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$SunX509
, SunJSSE: KeyManagerFactory.NewSunX509 -> com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$X509
, SunJSSE: TrustManagerFactory.SunX509 -> com.sun.net.ssl.internal.ssl.TrustManagerFactoryImpl$SimpleFactory
, SunJSSE: TrustManagerFactory.PKIX -> com.sun.net.ssl.internal.ssl.TrustManagerFactoryImpl$PKIXFactory
  aliases: [SunPKIX, X509, X.509]
, SunJSSE: SSLContext.SSL -> com.sun.net.ssl.internal.ssl.SSLContextImpl
, SunJSSE: SSLContext.SSLv3 -> com.sun.net.ssl.internal.ssl.SSLContextImpl
, SunJSSE: SSLContext.TLS -> com.sun.net.ssl.internal.ssl.SSLContextImpl
, SunJSSE: SSLContext.TLSv1 -> com.sun.net.ssl.internal.ssl.SSLContextImpl
, SunJSSE: SSLContext.Default -> com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl
, SunJSSE: KeyStore.PKCS12 -> com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore
]
TrustManagerFactory provider info: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
TrustManagerFactory default algorithm: PKIX
java.ext.dirs: C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "FIPS mode: only SunJSSE TrustManagers may be used". ClientConnectionId:48715f5b-a62e-45fa-aad9-6cc361d88672
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
 at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1668)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1323)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
 at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
 at java.sql.DriverManager.getConnection(DriverManager.java:582)
 at java.sql.DriverManager.getConnection(DriverManager.java:207)
 at sqlservertest.SQLServerTest.main(SQLServerTest.java:29)
Caused by: java.security.KeyManagementException: FIPS mode: only SunJSSE TrustManagers may be used
 at com.sun.net.ssl.internal.ssl.SSLContextImpl.chooseTrustManager(SSLContextImpl.java:95)
 at com.sun.net.ssl.internal.ssl.SSLContextImpl.engineInit(SSLContextImpl.java:60)
 at javax.net.ssl.SSLContext.init(SSLContext.java:248)
 at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1596)
 ... 7 more
Java Result: 1


Linked Server's Object reference crahses SQL Server Instance / Service

$
0
0

I have SQL Server 2012 Standard SP1 residing on Windows 2012 Server . Everything worked fine until I installed this fix ( http://support.microsoft.com/kb/2793634) . After this fix installation , any objects referencing linked server ( to Oracle ) does not work and it stops the SQL Server Instance / Service.

Surprisinly enough , tested the connection to linked server and it connected successfully ; but if refernce a table / view / synonym from the linked server , it crashes.

I see the following error in the event viewer.

Thanks for your help in advance.

Log Name:      Application
Source:        Application Error
Date:          6/13/2013 4:46:18 PM
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      devdbsql02
Description:
Faulting application name: sqlservr.exe, version: 2011.110.3128.0, time stamp: 0x50deadad
Faulting module name: ntdll.dll, version: 6.2.9200.16420, time stamp: 0x505ab405
Exception code: 0xc0000374
Fault offset: 0x00000000000ea485
Faulting process id: 0x6d0
Faulting application start time: 0x01ce687658da279f
Faulting application path: C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn\sqlservr.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 4b764d2d-d46a-11e2-93fe-ac162db2974a
Faulting package full name:
Faulting package-relative application ID:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" />
    <EventID Qualifiers="0">1000</EventID>
    <Level>2</Level>
    <Task>100</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2013-06-13T20:46:18.000000000Z" />
    <EventRecordID>13085</EventRecordID>
    <Channel>Application</Channel>
    <Computer>devdbsql02</Computer>
    <Security />
  </System>
  <EventData>
    <Data>sqlservr.exe</Data>
    <Data>2011.110.3128.0</Data>
    <Data>50deadad</Data>
    <Data>ntdll.dll</Data>
    <Data>6.2.9200.16420</Data>
    <Data>505ab405</Data>
    <Data>c0000374</Data>
    <Data>00000000000ea485</Data>
    <Data>6d0</Data>
    <Data>01ce687658da279f</Data>
    <Data>C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn\sqlservr.exe</Data>
    <Data>C:\Windows\SYSTEM32\ntdll.dll</Data>
    <Data>4b764d2d-d46a-11e2-93fe-ac162db2974a</Data>
    <Data>
    </Data>
    <Data>
    </Data>
  </EventData>
</Event>


Very Strange OPENROWSET Performance

$
0
0

Hello -

We're experiencing a very strange issue with OPENROWSET on our SQL 2008 Enterprise SQL Servers.  The configuration and end-goal are all pretty simple.  We have two SQL Servers on a LAN (same 1GB switch), a DB node and a DW node.  We want to run a simple OPENROWSET T-SQL query on the DB node to pull data from Analysis Services on the DW node (code sample below).  Here's the VERY strange issue...

An OPENROWSET query over a WAN connection start from a slow 3 yr old laptop is faster than when ran on a current gen server, on the same LAN as the server referenced in the OPENROWSET statement.  1 min over the WAN connection, 3-6 mins on a server on the same LAN.  We're baffled...

When the T-SQL query is ran from a "local" instance of the SQL Relational engine on our developers laptops (Win7, SQL 2008 with the OPENROWSET pointing to the DW node), the query returns in about 1 minute.  If we run the -exactly same query- from any Windows Server 2008 R2 server running SQL 2008, the query takes anywhere from 3-6 mins.

What's even more strange, when the developers are running the T-SQL query from their local laptops, the local SQL Server engine has to go over a WAN connection to get to the datacenter where the DEVDW01 server referenced in the OPENROWSET lives, which returns in about 1 min.  The Server2k8 test runs that return in 3-6 mins are on the same LAN and switch as DEVDW01!

We're tried updating SQL Server 2008 to SP3 from SP2, no change.  The only difference we could find between the developers Win7/SQL2008 setup and the Dev server Win2K8R2/SQL2008 configuration is that we're running SQL Server on the Dev Servers with a domain account, whereas the local laptop installs use NETWORK SERVICE.  So we changed the local laptop installations of SQL to use the domain account, and the query still completed in about the same time (about 1 min).

We're completely baffled... Can anyone make sense of this?

SELECT * 
       FROM OPENROWSET('MSOLAP','DATASOURCE=DEVDW01; Initial Catalog=App_Cube;',
              'DRILLTHROUGH MAXROWS 9999999999999999
              SELECT 
              FROM [AppCube]
              WHERE 
              (
                     [Snapshot Date].[Day].&[20130603],[App Cube].[Param1].[True],[IsAdmitWithinYear].[Param2].[True])
              RETURN
                           [Fact1].[Account Balance]'

Obviously I cut out some of our business logic, but the query really is that simple.  

Thanks,


passing column names and table name as parameters to function return value not working

$
0
0

ALTER FUNCTION [dbo].[UNIQUE_COLUMN_VALUE] (@var_pool_key INT,
   @var_in_table_name VARCHAR,
   @var_in_field_name VARCHAR)

   RETURNS  NVARCHAR(25)

AS

   BEGIN

    DECLARE @return_value_argument NVARCHAR(25)
    DECLARE @sql VARCHAR(250)


    SET @sql = 'SELECT ' + @return_value_argument + '= MAX(@var_in_field_name) + 1 FROM ' + @var_in_table_name + 'AS A WHERE A.POOL_KEY = ' + CONVERT(VARCHAR,@var_pool_key)  

    EXECUTE @SQL


    if (@return_value_argument = NULL)
    begin
        SET @return_value_argument = 1
    end

    RETURN @return_value_argument

   END

--------------------Execute function

SELECT [CCMS].[dbo].[UNIQUE_COLUMN_VALUE] (
  1625
  ,'INSTRUMENT_10001'
  ,'SESSION_ROW_KEY')
GO

Error

======

Msg 557, Level 16, State 2, Line 1
Only functions and some extended stored procedures can be executed from within a function.

Please help what to do?

                        

How to get update time of each record in a table?

$
0
0

Hi,

I want to get update time of each record in a table  (not for table).

Please suggest me possible solution.

Thanks in advance.

Using CDATA in SQL Stored Procedure Returning Typed-XML

$
0
0
I wrote a SQL Stored Procedure that returns a typed XML. The procedure works great. I have attached the stored procedure in a text file. Here is my problem. One of the columns in the table has data that will be invalid character in XML. I need to escape the data from this particular column ([ServiceContent]) as a CDATA. How can I do this in my stored procedure.

Akhtar

Incorrect syntax near 'AS'

$
0
0

Belove is the query which showing me as error in all the “AS”… Incorrect syntax near 'AS'


declare @Aint= 12;

                         declare @yr int = 13;

                         declare @S int = 3;

                         

                         (SELECT     Ctm,-SUM(Aammt)AS D

                           FROM          DBname.Schmaname.Tab1

                           WHERE      (Ayr= @yr + 1)AND(Vtn= 51)

                           GROUPBY Ctm)AS T ON @A = T.Ctm LEFTOUTERJOIN

                         (SELECT     Ctm,-SUM(Aammt)AS DDeduction

                           FROM          DBname.Schmaname.Tab1AS Tab1_1

                            WHERE     (Ayr = @yr+ 1) AND(Vtn = 45)

                           GROUPBY Ctm)AS DD ON @S= DD.CtmLEFTOUTER JOIN

                         (SELECT     Ctm,-SUM(Aammt)AS Bbbl

                           FROM          DBname.Schmaname.DebLBbbl

                           WHERE      (@yr <= @yr)

                           GROUPBY Ctm)AS B ON @S= B.Ctm

Viewing all 4164 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>