i am doing some insert or update on my db, and i want to dump the errors, if any, to a text file.
If the text file deosnt exist, then i want to create it. Then append data to it, in smthg like:
insert into mytable values (f1,f2,f3)
IF @.@.ERROR <> 0
begin
-- check if text file exist
-- if no create it and write 'an error occured etc...'
-- else append to it another line 'an error occured etc...
end
thanks for helping!!
Hi Terry,
If you're using 2000, then there really is no way to achieve what you are asking except to shell the command out via xp_cmdshell - which will do everything you asked with a little "creativity".
If using 2005, then your best bet would be to wrap the required functionality in a CLR stored proc. Again, BOL has some great info on this.
Cheers,
Rob