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

ADO Object was Open error aka DB_E_OBJECTOPEN on Large Dataset in MS SQL 2012

$
0
0

Hi I am running a query with a big result set in my Delphi application using tADOQuery.

When I request 12 months data I get an error "Object was Open".
But if I run the same query on 1 month of data it works fine.

The mechanism I use to open all queries in my application is the same and has always worked for many years.  This is the first time I have hit this error.  My application has run thousands of different queries across many customer sites without ever hitting this error.

In my research I found that this seems to correspond to an ADO Error DB_E_OBJECTOPEN.

The 12 month query runs perfectly OK in SQL Mgmt Studio and takes about 1.5 minutes to start showing results.  But it is 4 minutes before it works out there are 3,810,979 rows.

I am using a client cursor
myADOQuery.CursorLocation:=clUseClient;

And I am setting a large CommandTimeout = 600;

So why does the query fail in the ADO client (but it works in SQL Mgmt Studio)?

And what does this "Object was Open" error mean?



Access 2013 and Sql Server 2012 varbinary (max)

$
0
0

Hi,

I have a sql server 2013 database that stores signatures in varbinary(max) type.

I need to display those signatures on an access 2013 report.

Will Access 2013 support this?

Thanks,

George.

optimization

$
0
0

Hi,

I had a query something like this,I want to Optimize this Query further,Is it possible to remove the "NOT IN" and "IN" Keyword and optimize this Query to the furthest.I had tried some possibilities but it haven't reduced the time much.

SELECT   
      Employee,Name,JoiningDate,Status,      
      WorkingLocation
FROM  

SELECT       
        NULL AS Employee, Name,JoiningDate,Status,      
        WorkingLocation
FROM            
        EmployeeDetails WITH (NOLOCK)      
WHERE
        Status NOT IN (1,3,6)  AND RowStatus = 1
     
                UNION ALL  
   
SELECT        
       Fq.Name AS Employee, Cd.Name,JoiningDate,Status,WorkingLocation
FROM            
                 EmployeeDetails Fq WITH (NOLOCK)       
LEFT OUTER JOIN vwenEmployeeHDR Cd WITH (NOLOCK) ON Cd.Employee = Fq.Name  
WHERE
      Status IN (1,3,6)  AND RowStatus = 1
   
) EmployeeData  
   
 GROUP BY Employee,Name,JoiningDate,Status,WorkingLocation

During Index Maintenance Log exceeds as dramatically as it fulls the disk.

$
0
0

I found a solution to it that prior to Index Maintenence(Specially in case of Index Rebuild) first switch the database from Full recovery mode to Bulk-Logged Recovery Mode,then rebuild the index & again switch back to Full recovery Mode, as rebuilding index is minimally logged in bulk-logged recovery mode but fully logged in Full recovery mode. And switching to both modes does not breaks the log chain. 

But before implementing the solution I found an alarming article: Click Here

Although I have tested its concept and my backups were executed & restored successfully without any error. But it can be potentially disastrous if occur. So...

1. Is it even reliable? (Perhaps not. Seeking for experts advice)

2. What can be the alternative solution to restrict the log growth during index maintenance?

Curious & fingers crossed. Please revert.

Thanks in advance. 

 


Pranshul Gupta



error in Sqlserver ODBC dirver for linux

$
0
0

Hi All,

  I have installed the ODBC Driver manager and Sqlserver ODBC driver in one my RHEL 5.6 machine. got some error while invoking BCP & sqlcmd .. also i tried the connection its throwing error Is there any idea why i am facing this issue ? Installation seems fine ....

[root@vm-4BD1-4913 sqlncli-11.0.1790.0]# bcp
bcp: /lib64/libuuid.so.1: no version information available (required by bcp)
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
  [-m maxerrors]            [-f formatfile]          [-e errfile]
  [-F firstrow]             [-L lastrow]             [-b batchsize]
  [-n native type]          [-c character type]      [-w wide character type]
  [-N keep non-text native] [-q quoted identifier]
  [-t field terminator]     [-r row terminator]
  [-a packetsize]
  [-S server name or DSN if -D provided]             [-D treat -S as DSN]
  [-U username]             [-P password]
  [-T trusted connection]   [-v version]             [-R regional enable]
  [-k keep null values]     [-E keep identity values]
  [-h "load hints"]         [-d database name]

[root@vm-4BD1-4913 sqlncli-11.0.1790.0]# sqlcmd
sqlcmd: /lib64/libuuid.so.1: no version information available (required by sqlcmd)
sqlcmd: symbol lookup error: sqlcmd: undefined symbol: _ZNSbIcSt11char_traitsIcEN16BasicStringUtils21AutoClearingAllocator9AllocatorIcEEE4_Rep20_S_empty_rep_storageE

[root@vm-4BD1-4913 sqlncli-11.0.1790.0]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.6 (Tikanga)

[root@vm-4BD1-4913 sqlncli-11.0.1790.0]# uname -a
Linux vm-4BD1-4913 2.6.18-238.28.1.el5 #1 SMP Fri Oct 7 14:25:50 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

[root@vm-4BD1-4913 ~]# bcp master.dbo.sysdatabases out test.out -S VM-1842-7C16 -U test -P test123

bcp: /lib64/libuuid.so.1: no version information available (required by bcp)
SQLState = S1T00, NativeError = 0
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

[root@vm-4BD1-4913 ~]# cat .odbc.ini
[MSSQLTest]
Driver=SQL Server Native Client 11.0
Server=VM-1842-7C16,2431

Regards

Kamalakkannan

Issues with query using joins in 3 tables

$
0
0

I am trying to fetch data from 3 tables (Project,RIsk and Issues) using join. There are Risks associated with some projects and Issues associated with some projects.

ProjectID is primary key in Project table.

RiskID is primary key in risk table. ProjectID is foreign key.

IssueID is primary key in Issue table.ProjectID is foreign Key.

I need the projectname, count of risks for projects, count of issues for projects. I am using joins in all the 3 tables. Issue here is, its giving me double of count of risks and issues for each project.

Please advise how can I get the correct number. I have used the below query,

select p.projectname,count(r.riskid),count(i.issueid) from project as p

left outer join risk as r on p.projectid=r.projecctid

left outer join issue as i on p.projectid=i.projectid

group by

p.projectname

thanks

error...,

$
0
0

Select Error: SQLSTATE = 08S01

Microsoft OLE DB Provider for SQL Server

Connection failure,

please tel me how to fix fix this issues.

ODBC query execution fails with microsoft text driver

$
0
0

I'm trying to execute most simple possible query over text file with the text driver.Here's my script (it is a bat/jscript hybrid and should be saved as a.bat):

@if(@X)==(@Y)@end/* JScript comment @echo off rd /s /q C:\dbtest md C:\dbtest rem create a new "database" ( echo "col1","col2" echo "1","2" ) >>C:\dbtest\test.txt odbcconf configdsn "Microsoft Text Driver (*.txt; *.csv)" "DSN=testdns1|description=test_dns_1|defaultdir=C:\dbtest" cscript //E:JScript //nologo "%~f0" exit /b 0 */

var rs =newActiveXObject("ADODB.Recordset");var comm=newActiveXObject("ADODB.Command");var conn =newActiveXObject("ADODB.Connection");
conn.ConnectionString="testdns1";// read write
conn.Mode=3

conn.Open;
conn.Execute("Select  * FROM test");
conn.Close();

for 64bit machines:

@if(@X)==(@Y)@end/* JScript comment @echo off setlocal path %windwir%\sysWOW64\ rd /s /q C:\dbtest md C:\dbtest rem create a new "database" ( echo "col1","col2" echo "1","2" ) >>C:\dbtest\test.txt odbcconf configdsn "Microsoft Text Driver (*.txt; *.csv)" "DSN=testdns1|description=test_dns_1|defaultdir=C:\dbtest" cscript //E:JScript //nologo "%~f0" endlocal exit /b 0 */var rs =newActiveXObject("ADODB.Recordset");var comm=newActiveXObject("ADODB.Command");var conn =newActiveXObject("ADODB.Connection"); conn.ConnectionString="testdns1";// read write conn.Mode=3 conn.Open; conn.Execute("Select * FROM test"); conn.Close();

but at conn.Execute("Select * FROM test");  I'm receiving following error:

Microsoft OLE
DB Providerfor ODBC Drivers:[Microsoft][ODBC TextDriver]TheMicrosoftJet da
tabase engine cannot open the file '(unknown)'.Itis already opened exclusivel
y by another user,or you need permission to view its data.

The activex objects are created with jscript but is identical to vbscript (I've even used vbscript examples as reference).

Any idea what could cause this error?As the file is just created from the same user and nobody use it at the same time






Strange delay when executing procedures

$
0
0

Hi,

When migrating from SQL 2008 to SQL 2014 I come across a strange issue where some of our stored procedures always takes 500+ ms to execute (client side). The problem seems to be in the packet size together with the size of the columns.

Executing the procedure below on the client takes 500 ms. Bu just removing one character from a field name and the issue dissappears.

There is no delay if the test application is started on the SQL server itself - only on the clients. The firewall is off and there is no real time anti-virus running.

Any help is welcome

Regards

Robert Warnestam / CODAB AB

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

alter   Procedure [dbo].[co_Test1]
AS

SELECT 
	"1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx01L32xxxxxxxxxxxxxxxxxxxxxxxxxxx02","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx03L32xxxxxxxxxxxxxxxxxxxxxxxxxxx04","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx05L32xxxxxxxxxxxxxxxxxxxxxxxxxxx06","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx07L32xxxxxxxxxxxxxxxxxxxxxxxxxxx08","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx09L32xxxxxxxxxxxxxxxxxxxxxxxxxxx10","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx11L32xxxxxxxxxxxxxxxxxxxxxxxxxxx12","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx13L32xxxxxxxxxxxxxxxxxxxxxxxxxxx14","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx15L32xxxxxxxxxxxxxxxxxxxxxxxxxxx16","1" as "L32xxxxxxxxxxxxxxxxxxxxxxxxxxx15L32xxxxxxxxxxxxxxxxxxxxxxxxxxx160123456789012345678901234567" 


reading binary columns

$
0
0

I have a generic read routine that works great for every data type I have encountered so far.

But now I want to read a column that is defined as binary(20).

The read code is:

                   using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        int ivalCount = 0;
                        while ( rdr.Read()  )
                        {
                            while (ivalCount < iCount)
                            {
                                ne[ivalCount].Pt_Value = rdr[ivalCount].ToString();
                                ivalCount++;
                            }

                        }
 
                    }


The SQL table being read is:

name    	nvarchar(50)	Unchecked
VEC     	nvarchar(50)	Unchecked
stat	        smallint	Checked
lan	        smallint	Checked
unit	        smallint	Checked
flags	        int	        Checked
area_offset	int	        Checked
system_offset	int	        Checked
device_offset	int	        Checked
secondary_msg	varchar(50)	Checked
alarm_flags	smallint	Checked
pttype	        nchar(10)	Checked
web_message_id	varchar(50)	Checked
web_point_status nvarchar(50)	Checked
sockaddr_in	binary(20)	Checked
sockaddr_len	int	        Checked
		                Unchecked


It works great except for the "binary(20)" field.

In MS SQL Server Management Studio, the field appears as:

0x02000400C0A80062000000000000000000000000

But the code that reads the field gets:

"System.Byte[]"

Which strikes me as odd that the return would be the data type.  I sort of half expected a hexAscii string from the "toString"

My main problem is I don't know what data type any field is before reading it.

So what is the "best" way to read in the binary block, store it as hexASCII, not knowing first that it is a binary block?

Recommendations?

Boyd


BDM


Stored Procedure fails to return all rows of data.

$
0
0

Our HR database uses a procedure to build a list of employee IDs (ie. 1,3,14,...1210,1215) then calls a procedure to with a variable to extract details per employee. Unfortunately the list is 947 ids, however only 887 rows are returned.

As a test I split the list in two and called the procedure. If I add the data rows together I get 947, hence I know the employees are valid. Can anyone suggest why a long list of Ids should fail? Is there a limit a stored procedure can return?

The procedure (simplified down a bit) is:

----

ALTER PROCEDURE [dbo].[sp_Employee_CreateTable]
 @EmpIds varchar(4000)
AS
SELECT    E.empid as EmpId ,E.Surname
    FROM    Employee E
    WHERE  (E.[EmpID] IN (select * from GetAllUsersUnderManager(@EmpIds))) AND EJ.id=dbo.GetCurrentEmployeeJobRecord(EJ.empid)--EJ.dateto IS NULL

-----

I can run the procedure as:

"exec sp_Employee_CreateTable @EmpIds=N'1,3,14.....999'" which returns (say) 700 rows  and  "exec sp_Employee_CreateTable @EmpIds=N'1001,.....1215'" which returns 247 rows. (ie. 700+247 = 947 which is correct.

But exec sp_Employee_CreateTable @EmpIds=N'1,3,14......1215' only returns 887 rows.

I have looked at the length of the data passed to the procedure (1,3,...1215) which equals 4126 chars, therefore I bumped the varchar space from 4,000 to 6,000 which is still within limits, however the number of rows returned was still 887.

Any help would be gratefully received.


Few millions rows of data

$
0
0

Hi,

I have a prospect who is using Excel 2010 & has performance issues for data.

He would like to use Excel 2013 as GUI & would have 3 million rows (10 or 12 columns) & would like to retrieve data faster.

Can I suggest Azure here? If yes what would the architecture be?

Database Midification

$
0
0

Hi,

From example i am having 1 TB of data.

If suddenly client asks me that what is the used database  out of 1Tb.

In this case how to find out that used database?

SQL Server Expcts Value Where Field Is NullI

$
0
0

I am working on an application in Visual Basic 2010 using an SQL Server 2005 Express

The field in the database causing a problem is one of 25 similarly named fields(Track1 through Track 25 with several other fields preceding the tracks, My Visual Basic program consists of fields dragged form the data source.

When trying to add the first record to the database I get an error telling me that Track 20 is has a null value.  The exact message is "No Null Allowed Exception Was Unhandled" and identifies track 20 as the culprit.

I had deleted an re-dragged the control several time, checked and re-checked the table definitions in SQL Server To no avail.

Any suggestion?


sirmilt

Can't connect to SQL Azure database from development PC

$
0
0

Hi,

I can no longer connect to my SQL Azure database from my development PC. It started last week when the DNS stopped working. Then I switched the connection to the IP address and that worked until yesterday. Prior to that everything worked fine. 

PC is Windows 8.1. Last update was installed 3 days ago. 

ERROR is:  Exception message: Cannot open server "" requested by the login.  The login failed.

Can't connect through visual studio or SSMS. 

I am able to connect using DNS from another computer on the same network. 

Please help!

Thanks,

Brian

Entire Error

Exception message: Cannot open server "" requested by the login.  The login failed.

   Exception message: Cannot open server "" requested by the login.  The login failed.
Login failed for user ''.
This session has been assigned a tracing ID of 'a9d166d4-20b0-4279-82f6-1302f832a0d1'.  Provide this tracing ID to customer support when you need assistance.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Web.SessionState.SqlSessionStateStore.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval)


FileTable share folder problem.

$
0
0

Hi to all!

I have successfully set up a FILETABLE configuration on an Sql Server 2012 Standard edition. I am able to see the table "DocStore" in FileTables db-section, query the table and all are working ok.

Problem is that I cannot directly access the FileTable share folder on my server from another machine on my network, unless I create a login (Security/Logins) on my db-server for the user that I want to to have access from.

For example:

The FileTable share folder on the database server is "\\silo\mssqlserver\DocStore\Data". If I want to access it from a pc that mydomain\user1 is logged in, I have to create a login in db-server"silo" for that domain user. Then I can see the folder in any machine that mydomain\user1 is logged in and then be able to copy folders and files in it so they can be reflected on the FILETABLE. As this will not work for me well in the scenario I am dealing with, is there another way to access the FileTable share folder *without* being forced to create a login for every user I want to put files in ?  Thanks a lot, in advance, for any help.

Weird error message from C#

$
0
0

Hi everybody,

I have a relatively complex SQL Statement I am passing to SQL Server from C# application. This statement start from BEGIN TRANSACTION

insert 

insert 

insert

COMMIT TRANSACTION

-----------------------

I am getting this error

The parameterized query '(@sale_no decimal(8,0),@scanDate datetime,@start_date datetime,@' expects the parameter '@operator'

------------------------

So, first of all, why does it show this strange part of the query and secondly, I do supply the @operator parameter (although it was assigned null value which is a mistake and I need to fix it).

Still, why I am getting this strange error?

Thanks in advance.

E.g. I have the following code:

  /// <summary>
      /// Adds salespoint and operator parameters to the SqlCommand
      /// </summary>
      /// <param name="sqlCommand"></param>
      public void AddOperatorAndSalespointParameters(SqlCommand sqlCommand)
      {
         sqlCommand.Parameters.Add("@operator", SqlDbType.Char, 6).Value = this.CurrentOperator;
         sqlCommand.Parameters.Add("@salespoint", SqlDbType.Char, 6).Value = this.CurrentSalespoint;
      }

and at the moment of execution both variables were null.

-----

UPDATE. After I fixed the NULL values, the error disappeared. Still, I find it misleading.


For every expert, there is an equal and opposite expert. - Becker's Law


My blog


My TechNet articles



application role does not see stored procedures using SSMS

$
0
0

I have an application role called Myapp and I grant execute permission to stored procedures, but I can not see the user stored procedures when I log in as Myapp.

I can see stored procedures when I log in as my ID and checked MyApp has execute permission for the procedures.

Are there any rights to set in order to see them on SSMS?

I am using SQL Server 2008,

Your help and information is great appreciated,

Regards,

Souris,


Can't Share SQL Server 2000 in Windows 7 Pro

$
0
0
I had installed SQL Server 2000 in my Windows 7 Professional and use in it in this PC. But Can't Use in my network Group Windows 7 Professional and Windows Xp, Can I Solve This Issue?

Query retreival

$
0
0

Hi,

   I had one view ,the select statement in the view consists of only one table called " vwenallocationHDR" it consists of 40 columns and 40 + lakhs of data, the indexing is done Clustered index is set for 2 columns, and the non- clustered index is created for 3 columns and rest of all the columns are added as Covered indexes .So i don't think there is an indexing issue..

But when i select all the rows without specifying any where ondition it is taking 20 + minutes to retreive all the 40 lakh data,i know we are not specifying any conditions so obviously it will do index scan that's why it is taking so long time.is there any way to improve that?

Secondly,i tried with one where condition which is applied on a column on which the non- clustered index is applied.then it's still taking more than 50 seconds,how can i reduce this? does table partion will help ? if does how you create view based on the partitioned table?

Viewing all 4164 articles
Browse latest View live


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