August 28, 2006 at 2:54 am
Hi!
Is there any way to store the results of the "Messages" tab of the query analyzer into a table?
I need it to compose a log file.
Thank you!
August 28, 2006 at 7:04 am
I'v got it just by using xp_cmdshell and ISQL dos command:
INSERT dbo.OneTable (Line)
EXEC master..xp_cmdshell 'ISQL -q"EXEC dbo.sp_OneProcedure" -Sserver\instance -Uuser -Ppassword'
Regards!
August 31, 2006 at 2:23 am
Problem!
This last mentioned way the call to xp_cmdshell will never return an error even if 'ISQL -q"EXEC dbo.sp_...' fails.
I need to catch if there was an error, and store the error message.
If tried this:
EXEC dbo.sp_myprocedure
IF @@ERROR <> 0
SET @ErrDesc = (SELECT description
FROM master.dbo.sysmessages
WHERE error = @@ERROR)
But it displays %s, %d, etc instead of the real object names involved in the error. How could I catch the full error message as displayed in Query Analyzer?
Thanks so much!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply