Showing posts with label interact. Show all posts
Showing posts with label interact. Show all posts

Thursday, March 29, 2012

Error List, Sql Server 2005

Hello, I would like to know if there is an list of mistakes where appears all errors that you can find to interact with the SQL.

for example something similar like this:

Error number 2627 Means that exists a record with the same primary key

Error number 505 Means that ther is a row with doesn't accept nulls

Thanks, my email pac_mt@.hotmail.com .

Are you looking for the possible error messages? You can query master.dbo.sysmessages in older versions of SQL Server and sys.messages in SQL Server 2005. Older versions of Books Online also has the list of error numbers/messages.|||

The problem is that sysmessages doesn't contain all error numbers. For instance, I can't find the error 1326: An error has occurred while establishing a connection to the server...

Why are not all errors documented and is there any unofficial documentation where I can find the full list of errors?

Thanks

|||

1326 is not a SQL Server error message. It is raised by the client data access library. All the error messages raised by server should be present in the system table. But not all error messages may be documented in Books Online. If you find such errors and would like to see it documented then please use the feedback mechanism in Books Online to submit a work item. This is the best way to send feedback for documentation issues.

See below topic for SQL Server 2000 error messages:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/trblsql/tr_syserrors1_6m5z.asp

And btw, the latest update (July 2006) of SQL Server 2005 Books Online contains the error message topics too. See below links:

http://msdn2.microsoft.com/en-us/library/aa337472.aspx

http://msdn2.microsoft.com/en-us/library/ms365262.aspx

http://msdn2.microsoft.com/en-us/library/ms165761.aspx

|||

Thanks.

I actually decompiled System.Data.SqlClient yesterday and noticed these connection errors come from dbnetlib.dll

These error messages, thrown by ado.net as SqlExceptions, are really hard to identify as there are dozens of different error numbers for the VERY same error description (like 5, 51, 121, 231, 1326) and sometimes they overlap the native SQL Server errors.

I'll also post this to a ADO.NET forum. Thanks again.

sql

Friday, February 17, 2012

Error Handling with openrowset

I am using openrowset to interact with some fox pro tables.
I want to be able do error handling if the openrowset quiery fails.
When the quiery gets and error it terminates and does not seem to return and
error status.
Here is a code sample.
Update openrowset('MSDASQL',
'Driver={Microsoft Visual FoxPro
Driver};UID=;PWD=;SourceDB=\\dataserver\prod\apps\ tele\;SourceType=DBF;Exclusive=No;Background
Fetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes',
'select PROMO_CODE from prospect_conf
where area_code+home_phone in (select parea_code+phome_phon from
prospext_conf
where ctod(misc5) = date())')
set promo_code = LEft(promo_code,3)+'0'
Thanks in advance
Regarding Trapping the error from an OpenRowset failure.
I have had similar problems using OpenRowset with FoxPro tables, and found the workaround to be as follows.
1. Build the Openrowset query inside a stored procedure.
2. Call that procedure from inside a parameterised DTS package (Exec usp_Procname ?,?,?)
3. Call the DTS package from another stored procedure.
The DTS package will return a trapable error, so if you are trying to do some type of batch processing your process can continue on.
Admittedly it's a bit convoluted, but it works.