Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Empty String Stored Procedure Parameters

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-22 : 10:05:37
Corey writes "You've created a SQL statement string that contains a call to a stored procedure with parameters. Some of your parameter values contain empty strings, i.e "". You open an ADO Connection and use the Execute method to execute the SQL statement.

If you opened the ADO Connection using the Microsoft SQL Server ODBC Driver, it works. However, if you opened the ADO Connection using the Microsoft OLE DB Provider for SQL Server, it fails with the following message:

***
Microsoft OLE DB Provider for SQL Server error '80040e14'

Cannot use empty object or column names. Use a single space if necessary.
***

Now, the ADO Connection connection strings(for ODBC and OLE DB) are just basic, and use all default settings. For example:

OCBC ==> "Driver={SQL Server}; UID=MyID; PWD=MyPwd; Server=MyServer; Database=MyDb; "
OLEDB ==> "Provider=SQLOLEDB; User ID=MyID; Password=MyPwd; Data Source=MyServer; Initial Catalog=MyDb; "

This problem occurs with all recent versions of MDAC and all Windows operating systems. Tests were performed on development, production and "CLEAN" machines. It appears to be by design.

Is there a way to eliminate the need to put spaces in "empty string" stored procedure parameters? Assume that the Execute method of the ADO Connection object is always to be used.

Thanks, and good luck."

royv
Constraint Violating Yak Guru

455 Posts

Posted - 2002-01-22 : 10:15:54
I replace all empty strings with the text NULL. You still have to replace the empty string values, but I thought it might help.

*************************
Just trying to get things done
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-01-22 : 11:51:28
I have db interface routines to create the parameters.
An empty string is set as an empty string but with length 1 (same as with null). That ends up as an empty string in the stored proc.

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -