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 2005 Forums
 Transact-SQL (2005)
 How can i find out what caused insertion failure?

Author  Topic 

obscure
Starting Member

6 Posts

Posted - 2009-11-18 : 10:39:29
Hi all.

I have an application which inserts a new row into a table. If this insertion fails, the query is stored in a log file. The problem is, the inseriton is failing form time to time, without any signs. If i take the query from the log file and run it from the query manager, it succeeds.

I have no way of knowing what the error message of the failed insertion is from the application, so i was wondering if there is a log in the database i can search. Is it possible to create a transaction log and check in it for failures?

Using the profiler is not an option, as it will slow down the system, and the operations are time critical.

Thanks for you help.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-18 : 10:43:52
if this is a homegrown app, have the application log the exact error

a narrow, focused trace won't slow down the system too much if you have some idea of what you're looking for. but if the app was logging the error it'd be real easy :)
Go to Top of Page

obscure
Starting Member

6 Posts

Posted - 2009-11-18 : 11:59:12
Can I use the profiler to monitor a specific table only? If so, will it affect the performance less than monitoring the whole database?
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-18 : 12:12:52
yes and yes
Go to Top of Page

obscure
Starting Member

6 Posts

Posted - 2009-11-18 : 12:23:12
Ok, how?

I searched the web but really couldn't find anything i could make sense of.
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2009-11-18 : 15:21:39
quote:
Originally posted by obscure

Ok, how?

I searched the web but really couldn't find anything i could make sense of.



I don't think you can trace a specific table.

But you can trace a specific Stored Procedure:
- On the events, select all events for the event group 'Stored Procedures'
- For the Column filtes, the filter is 'ObjectName', put the Stored Procedure name there and check the 'Exclude Rows...'
Go to Top of Page

obscure
Starting Member

6 Posts

Posted - 2009-11-18 : 15:28:12
And can I see what the returned execution error is?
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-18 : 16:24:20
you can filter for all procs known to touch the table in question and all SQL batches where text like table in question

can find which procs touch it in information_schema.routines or syscomments views
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2009-11-19 : 12:08:18
quote:
Originally posted by russell

... and all SQL batches where text like table in question



Ah...
Thank you.
Go to Top of Page

obscure
Starting Member

6 Posts

Posted - 2009-11-21 : 05:29:19
quote:
Originally posted by denis_the_thief
I don't think you can trace a specific table.

But you can trace a specific Stored Procedure:
- On the events, select all events for the event group 'Stored Procedures'
- For the Column filtes, the filter is 'ObjectName', put the Stored Procedure name there and check the 'Exclude Rows...'




Ok, i did just this, but don't see the error message returned anywhere. How can i see what the returned result is... success or failure.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-11-21 : 10:03:37
http://blogs.sqlserver.org.au/blogs/greg_linwood/archive/2006/03/29/70.aspx
Go to Top of Page

nalnait
Starting Member

14 Posts

Posted - 2009-11-22 : 04:20:51
u can use try...catch
Go to Top of Page
   

- Advertisement -