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

ODBC call SQLFetch slower when MARS is enabled

$
0
0
We are connecting to a SQL Server 2008 R2 instance using ODBC and the performance of a SELECT query is significantly slower when MARS is enabled on the connection. I tried different driver versions (SQL Server Native Client 10.0, SQL Server Native Client 11.0), but the MARS connection is always significantly slower. I expect the time taken by the query in the MARS connection to be on par with the time taken with MARS off, as I am only running one query at a time without any interleaving.

About the SELECT query:
I am yet to look into other queries, but this one query which has multiple joins is slower with MARS on. The query returns 600K+ rows. I have pasted the query further below.

Simplistic work flow:
a) Connect to a SQL Server 2008 R2 instance using ODBC
b) SQLPrepare the query
c) SQLExecute
d) SQLFetch multiple times until it returns SQL_NO_DATA

When MARS is OFF:
SQLExecute takes around 7 seconds
When SQL_ATTR_ROW_ARRAY_SIZE is set to 100, SQLFetch is called 6000+ times, and total fetch time (across 6000+ SQLFetch calls) is under 300 milliseconds
My application typically gets the complete result set (600K+ rows) in 7.5 seconds (i.e. from issuing the query to receiving the last row).

When MARS is ON:
SQLExecute takes around 7 seconds
When SQL_ATTR_ROW_ARRAY_SIZE is set to 100, SQLFetch is called 6000+ times, and total fetch time is 30+ seconds.
I experimented with different row sizes, but the total fetch time is typically 30+ seconds, as the time spent in each SQLFetch call increases when the row size is set to a higher number.
My application typically gets the complete result set (600K+ rows) in about 40 seconds (i.e. from issuing the query to receiving the last row).

I experimented with different cursor types (including SQL Server specific FAST FORWARD-ONLY cursor with and without autofetch), SQL_ATTR_CONCURRENCY, SQL_ATTR_CURSOR_SCROLLABLE and SQL_ATTR_CURSOR_SENSITIVITY. I experimented with different row fetch sizes too. But I have not been able to improve the performance of the query with MARS enabled. 

I feel that MARS is using a cursor, while default result sets (“firehose cursors”) are being used when MARS is off; although it is claimed in the Microsoft documentation that default results are the default when MARS is enabled.

The query I am using is below. I haven’t specified the data types of each column used in the query, but I am going to skip that for now. I can definitely provide that if that information is necessary to solving this problem.

Maybe my query has some characteristic that is causing MARS to not use default result sets? Anything I can try to speed up my query under MARS? We need MARS to be enabled on our application.

SELECT [G].[iteration] AS [iter],
  [A].[area] AS [area],
  [B].[status] AS [status],
  DATEADD(minute, DATEDIFF(minute, 0, [B].[dt]), 0) AS [mydate],
  MAX([Z].[title]) AS [title1],
  MIN([Z].[title]) AS [title2],
  MAX((CASE
	WHEN 0 = ISNUMERIC(CAST([G].[estimate] AS VARCHAR)) THEN NULL
	ELSE CAST(CAST([G].[estimate] AS VARCHAR) as float) END)) AS [calculation]
FROM [dbo].[Z] [Z]
  INNER JOIN [dbo].[A] [A] ON ([Z].[idA] = [A].[idA])
  INNER JOIN [dbo].[B] [B] ON ([Z].[idB] = [B].[idB])
  INNER JOIN [dbo].[C] [C] ON ([Z].[idC] = [C].[idC])
  INNER JOIN [dbo].[D] [D] ON ([Z].[idFF] = [D].[idFF])
  INNER JOIN [dbo].[E] [E] ON ([Z].[idP] = [E].[idP])
  LEFT JOIN [dbo].[F] [F] ON ([Z].[idB] = [F].[idB])
  LEFT JOIN [dbo].[G] [G] ON ([Z].[idB] = [G].[idB])
  LEFT JOIN [dbo].[H] [H] ON ([B].[idQ] = [H].[idQ])
  INNER JOIN [dbo].[J] [J] ON ([Z].[idB] = [J].[idJ])
WHERE (([A].[area] >= 'AA') AND ([A].[area] <= 'ZZ'))
GROUP BY [G].[iteration],
  [A].[area],
  [B].[status],
  DATEADD(minute, DATEDIFF(minute, 0, [B].[dt]), 0)



ADODB Auto Translate Issue

$
0
0

We had an legacy classic ASP application in windows 2003 web server and IIS 6.0. It utilized ADODB with ODBC driver (Connection String: "DSN=CO_SQL_SERVER;DATABASE=DOC;UID=xxxx;PWD=yyyy") to access a VARCHAR  comment field in a Database with collation SQL_Latin1_General_CP1_CI.

We migrated the application to Windows 2008 R2 server and IIS 7.5. We retained the utilization of the same SQL Server database setting, but using integration Security Driver:

"{SQL Server}; Server=COMSSQL;DATABASE=COMS;Trusted_Connection=Yes;AutoTranslate=No"

However, the data returned seemed to be turned into UNICODE, even with the AutoTranslate set to no.

What did we do wrong? What would be the proper setup to disable the auto translation?

Thanks.

Sai Kit Tong

Error in Loading dll

$
0
0

I have Windows 7 (64bit) computer

When I used access 2003 and now access 2007, I get an error when I am using a wizard, such as the form wizard. The error is "error in loading dll".  The forum articles I have read are over my head. What I understand is that I am missing a MDAC file or have one that doesn't match my situation. Help

Linked server: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

$
0
0

Hi ALL,

I have two SQL Server instances (s1 and s2). Both are sql server 2008r2. And they are not in same computer. I make s2 as linked server and add it to s1. And then, I want to query two tables from s1 and s2 in third computer. In third computer, I make a connection to connect s1 by SSMS. And then I write down a simple code:

                              "SELECT CountyID, CountyName, Shape FROM [s2].MyDB.dbo.countyBoundariesTable"

When I run it, error message says: "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.".

My user account is configured to map to sysadmin on s1. And it is permitted to read MyDB in s2 only.

Any thought?

Thanks!

Accidentally upgraded database to 706

$
0
0

A web project I am working uses an SQL 2008 database that is distributed along with the app so it can be setup to run on several OS systems including XP. However, during an editing session using Visual Studio 2012 for web the master copy of the 665 version was inadvertently upgraded to 706 when Visual Studio loaded the project ... remember just say no to version upgrades :) ... now the XP machines that have SQL 2008 will not load the distributed database and produce an error saying that the database is version 706 and the machine's server only supports 665 and earlier.

My question is this:

Is there a way to recreate a 665 database on an 2008 SQL server version and then "import" the tables and the data to the 665 version from the 706 version without automatically upgrading the 665 version to 706? I have tried creating a blank database on an SQL 2008 server and then attaching both the 665 and 706 databases to the 2012 server and exporting from the 706 version to the blank 665 database. However, each time the import is complete the new database somehow changes to version 706, and the SQL server 2008 server will no longer load it even though it was created on the 2008 server. I am careful to select Native Client 10 for the import to the 665 version and Native Client 11 for export from the 706 version, but this does not seem to help.

Any suggestions? I am stumped!

David

Issue in configuring Change Data Capture

$
0
0

I am getting the following error message while trying to configure CDC ... Pls advice to rectify this issue...

Executed Query:

EXEC sys.sp_cdc_enable_table
@source_schema = N'dbo',
@source_name   = N'Employee',
@role_name     = NULL,
@filegroup_name = N'PRIMARY',
@supports_net_changes = 1
GO

Error Message:

Msg 22832, Level 16, State 1, Procedure sp_cdc_enable_table_internal, Line 623
Could not update the metadata that indicates table [dbo].[Employee] is enabled for Change Data Capture. 
The failure occurred when executing the command '[sys].[sp_cdc_add_job] @job_type = N'capture''.
The error returned was 22836: 'Could not update the metadata for database test to indicate that a Change Data Capture job has been added.\
The failure occurred when executing the command 'sp_add_jobstep_internal'.
The error returned was 14234: 'The specified '@server' is invalid (valid values are returned by sp_helpserver).'. 
Use the action and error to determine the cause of the failure and resubmit the request.'. 
Use the action and error to determine the cause of the failure and resubmit the request.

My Current Version:

Microsoft SQL Server Management Studio11.0.2100.60
Microsoft Analysis Services Client Tools11.0.2100.60
Microsoft Data Access Components (MDAC)6.1.7601.17514
Microsoft MSXML3.0 6.0 
Microsoft Internet Explorer9.10.9200.16736
Microsoft .NET Framework4.0.30319.18052
Operating System6.1.7601

Connect SQL SERVER 2008 to UNIDATA

$
0
0
Hello everybody
I need your help please, Somebody know how connect SQL SERVER TO UNIDATA, I mean I need create one connection to Unidata and then download data to SQL SERVER 2008, I have a ODBC DRIVER UNIDATA IBM cretaed. Please Help ME 

Restoring .bak

$
0
0
long story, so i'll keep it short - 

Was using Windows Authentication to connect to the server. The Windows Account was deleted. Now i can't get in. 

I have .bak (full). Can I just install another Server Instance and restore those .bak's or do they require the old authentication, 

thanks
frank

log in failed connecting vb2008 to sql server 2005

$
0
0
Good day...my 0s is windows 8, i'am trying to connect vb 2008 to sql server 2005...i've carefully follow the procedure but it promt always lo in failed to the user...please help me!!!

Multiple values in IN Operater

$
0
0

Hello,

I have written a query with In Operator in store procedure , I would like to pass the value to IN clause from Store procedure parameter.

Ex- create procedure SP_Name (@var as varchar(50))  --[Passing value for example 'John,Jack,Jems,Catrina']

begin

select * from tblName where clmName IN (@var)

end

Whenever i try to do this i will get an error that IN operator will take only integer value.

Could you please help me to resolve this issue.

SQL server 2008 double hop authentication issue in linked server occuring intermittently

$
0
0

Hi ,

We have three servers say A, B, C. SSMS available in Server A connects to the instance of SQL installed in server B and runs a query. The query has a linked server in it which is C. This login where the query is running has permissions in all the machines.

The issue we see is sometimes the connection get succeeded and sometimes it fails with message

LOGIN FAILED FOR NT AUTHORITY/ANANOYMOUS LOGIN:

Any suggestion to find out where the issue will be

How to manage a data processing project

$
0
0

I need to write a load of scripts to process data. My workflow is view "raw data", write some C# scripts and view the "output data".

I've started a "Console Application" project which connects to a SQL DB. It then processes the data and creates a new table. Is there a command I can use to open the table in SQL Server Object Explorer automatically?

Is there a better workflow I can use?

How to turn off sp_prepexec for Stored Procedures in JDBC Driver

$
0
0

I am using Microsoft JDBC Driver 4.0. 

When my application executes a PreparedStatement or CallableStatement, like this - 

PreparedStatement pstmt = con.prepareStatement("{call dbo.getEmployeeManagers(?)}");
pstmt.setInt(1, 50);
ResultSet rs = pstmt.executeQuery();
rs.close();
pstmt.close();

I see, via SQL Profiler, that sp_prepexec is called. It prepares the statement and executes it in one round trip, returning the results of the execution and a prepared statement handle to be used in any subsequent executions.When the application later closes that previously executed statement,  the sp_unprepare call closes the prepared statement handle created earlier by sp_prepexec.

declare @P1 int
set @P1=1
exec sp_prepexec @P1 output, N'@P0 int', N'EXEC getEmployeeManagers @P0', 50
select @P1

exec sp_unprepare 1
      

I understand that good use of a Prepared Statement is when we prepare once and then reuse the statement object for subsequent calls. But most programming advice for DB Access say that it is good practice to release resources as soon as you are finished with them to avoid tying up database resources.  

This renders the prepared statements useless, especially for stored procedures. In the case where a sproc is executed only once, the overhead to generate a prepared statement handle and the separate round trip needed to close it may have some performance impact. Futhermore, tracing in SQL Profiler becomes difficult since the calls are wrapped in a sp_prepexec. 

Is there a way to in driver to turn Prepared Execution off, and have the driver just call the stored procedure directly? 

exec getEmployeeManagers @P0=50


Thanks, 

Rohit

ODBC API to retrieve User-Defined DataType of a Column in a ResultSet ?

$
0
0

Hi,

ODBC APIs such as SQLDescribeCol(), SQLColAttribute() could be used to retrieve SQLDataType of a particular column in a ResultSet.

Similarly, Is there any ODBC API which could be used to retrieve User-Defined DataType of a particular column in a ResultSet?

-Vengatesh

 

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection error only when using ApplicationPoolIdentity in IIS 7.0

$
0
0

I have an ASP.NET web application that uses integrated security in IIS 7.0 to connect to a remote SQL Server instance. When using the ApplicationPoolIdentity in the DefaultAppPool application pool or a new application pool dedicated to the application I get the following error:

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

I have disabled all authentication modes in IIS except Wnidows Authentication.

I have created and set permisions on the MACHINE_NAME$ windows account in SQL Server. I do not get the error when the application pool Identiy is set to NetworkService, so I know the security configuration is correct and that Kerberos is running correctly. I do not want to use the NetworkService account.

My understanding is that both the ApplicationPoolIdentity and NetworkService setting use the MACHINE_NAME$ identity for remote server connection. So why does this not work for ApplicationPoolIdenty.

Any help would be appreciated.


Excel 2013 64 bit not able to retreive data from Access 64 bit querry with a linked table to a SQL server 2012 Great Plains Dynamics 32 bit

$
0
0

Hello,

 I m trying to using excel 2013 64 bit to get external data from an Access 64 bit query.  this query is a simple query to  a linked Great Plains Dynamics  table located to a SQL 2012 server   and I got this message:

The query did not run, or the database table could not be
opened.

Check the database server or contact your database
administrator. Make sure the external database is available and hasn't been
moved or reorganised, then try the operation again.

I use a lot of these query on Excel 2010 32 bit and access 32 bit with complex query and it worked fine.

Now  I am not able to use theses query with Office 2013 64 bit. 

Weird thing is that Access 2013 64 bits is able to retrieve data but not excel linked to Access

I tried many combination of ODBC 32 bits  / 64 bits

Does it a a special drivers for EXCEL?

Does it have a solution other than uninstall office 64 bits and install a 32 bits version ?

How to create index in virtual Column in SQL Server

$
0
0

I want to create index in virtual column in Microsoft SQL Server 2005

WITH OrderedOrders AS(SELECT*, ROW_NUMBER()OVER(ORDERBY I_D)AS RowNumber FROM ST_Agency_TblWHERE  Delete_Flag <>1)SELECT*FROM  OrderedOrders WHERE  RowNumber >=8000000AND RowNumber <=8000100

Can I create index in RowNumber? 

I use RowNumber as serial column 1,2,3,.... but when I execute Above query , Execution time between 2 - 3 minutesCan I use alternative method to generate serials without using ROW_NUMBER() ?

Microsoft JDBC driver 3.0 on JRE 1.6.21(32bit) failed to connect to MSSQL

$
0
0

Our java application sometimes has problems getting new connections.  An Error occur, everyday after restarting the machine.

  • Client OS: Microsoft Windows 2008r2 SE x64 (Our java application and SQL Server are same machine)
  • JDBC Driver:  "Microsoft SQL Server JDBC Driver 3.0" VERSION "3.0.1301.101"
  • Java: JRE 1.6u21(32bit)
  • SQL Server: Microsoft SQL Server Standard Edition (64-bit) 10.50.1617.0
  • Windows task scheduler calls our application every 11PM.

My Questions are:

  • Did Jdbc Driver try to write any log?  Why JDBC Driver couldn't write any log?
  • What does this error indicate?

Error message:

TDSChannel (ConnectionID:1) write failed:Connection reset by peer: socket write error
com.microsoft.sqlserver.jdbc.SQLServerException logException

JDBC driver log(Stacktrace):

 (): Connection reset by peer: socket write error
java.io.IOException: Connection reset by peer: socket write error
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:594)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:664)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:656)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:851)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:839)
    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
    at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1483)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1042)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at jp.co.intec.idms.core.operation.db.DBManager.openImpl(DBManager.java:149)
    at jp.co.intec.idms.core.operation.AbstractOperation.open(AbstractOperation.java:80)
    at jp.co.intec.idms.core.datastorage.impl.DbDataStorageImpl.open(DbDataStorageImpl.java:204)
    at jp.co.intec.idms.core.datastorage.impl.TempDataStorageImpl.open(TempDataStorageImpl.java:153)
    at jp.co.intec.idms.core.framework.manager.impl.AbstractConnector.doSelect(AbstractConnector.java:182)
    at jp.co.intec.idms.core.framework.manager.impl.AbstractConnector.syncData(AbstractConnector.java:121)
    at jp.co.intec.idms.core.framework.manager.impl.FunctionalUnitImpl.doAction(FunctionalUnitImpl.java:100)
    at jp.co.intec.idms.core.framework.manager.impl.FunctionalUnitImpl.execute(FunctionalUnitImpl.java:52)
    at jp.co.intec.idms.core.framework.manager.impl.ScheduleImpl.execute(ScheduleImpl.java:100)
    at jp.co.intec.idms.core.framework.manager.impl.DefaultControl.start(DefaultControl.java:90)
    at jp.co.intec.idms.core.framework.manager.main.YuitoCore.main(YuitoCore.java:149)
2013/08/28 23:11:32 com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
INFO: java.security path: C:\Program Files (x86)\Java\jre6\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]
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
]
java.ext.dirs: C:\Program Files (x86)\Java\jre6\lib\ext;C:\Windows\Sun\Java\lib\ext



Find Parents of Parents and updating their values in database which is having some hiearchial data

$
0
0

I am trying to get all parents of a specific user and update it values. what i want exactly is..

My data is something like this

Here there are many pairs which are being made,where a pair mean a user in left hand and a user in right hand, i am able to track users at level 1 , i.e Child1 has two childs A & B and so on, but there are many more Pairs which are Being formed.See the Next Image.

Now in this pic, relationships in red are level 1 childs and parents, rel in blue are level 2 relationships and relationship in green are level 3 one's.

Here what i want is whenever a level2 or level 3 pair is made whenever a child is added, i could trace that or i want a logic to check wether the pair is being formed or not. This is minimal data .actual database will contain 5 to 10000 of entries, each time i add a user , i have to check for all the users which are in his tree ,i.e parent of new child added, parent of this child's parent and so on. For each one i have to chek if a pair is formed, either at level1 , level 2 , level3 and update their amont likewise.

Database modification is possible i.e if any column needs to be added

IdNameGenderSponsorIDPairSide
1000 RootM1000TOP
1001Child1F1000Left
1002Child2M1000Right
1003A M1001Left
1004B M1001Right
1005M M1002Left
1006N M1002Right
1007C F1003Left
1008D F1003Right
1009EM1004Left
1010F F1004Right
1011O M1005Left
1012P M1005Right






Please provide the logic for this problem , Its Critical


Vishal Kumar Singh


Viewing permissions for users on Jobs in SQL 2008 server

$
0
0

How can i give viewing permissions for user(s) on jobs in SQL 2008 server.

We can add users to "SQLAgentReaderRole", but that gives users access to create jobs on the server which we do not want.

Is there any other way, i can give user(s) access to view sql jobs and history of the jobs without giving them access to create jobs.

Viewing all 4164 articles
Browse latest View live


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