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 2008 Forums
 Transact-SQL (2008)
 Update error message

Author  Topic 

avijit_mca
Posting Yak Master

109 Posts

Posted - 2010-07-22 : 05:28:37
i am running update script.

begin try
update table t1
set a=2,b=2

end try
begin catch

select 'table t1 not update' + @@error_message()
end catch


begin try
update table t2
set a=2,b=2

end try
begin catch

select 'table t2 not update' + @@error_message()
end catch


........ cont...
say in second update command , colum b not exists.
if u run it Query manager ,in message section its coming
Error message coming 'Invavalid command'

But i want this message in result set or in catch block.

Because i hv to run this query from ssis package & i m cathing all the error by result set.
need help.........

Regards,
avijit

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-22 : 05:43:57
The following types of errors are not handled by a CATCH block when they occur at the same level of execution as the TRY…CATCH construct:
- Compile errors, such as syntax errors, that prevent a batch from running.

- Errors that occur during statement-level recompilation, such as object name resolution errors that occur after compilation because of deferred name resolution.

See here for more info:
http://msdn.microsoft.com/en-us/library/ms175976(SQL.100).aspx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -