The SQL-Serveragent runs jobs which execute the SQL-Files:
(e.g. osql /E /n /i \\server\d$\lager_pool.sql)
How can I implement an error handling.
If an error occurs, the script stops, and I can't read the variable
@.error
My script - table xy doesnt exist
SELECT * FROM XY
SELECT @.@.error
SELECT 33
The execution stops with an error after the first line
Thanks for your help.
aaapaulHi
Look at using the -b flag when you call osql, there is more information in
Books Online.
John
<lvpaul@.gmx.net> wrote in message
news:1128067412.114048.12840@.g44g2000cwa.googlegro ups.com...
I am using SQL Server 2000. I have some files with SQL-Statements.
The SQL-Serveragent runs jobs which execute the SQL-Files:
(e.g. osql /E /n /i \\server\d$\lager_pool.sql)
How can I implement an error handling.
If an error occurs, the script stops, and I can't read the variable
@.error
My script - table xy doesnt exist
SELECT * FROM XY
SELECT @.@.error
SELECT 33
The execution stops with an error after the first line
Thanks for your help.
aaapaul|||Thanks, but it doesnt work
This is my script - its a file c:\test.sql
declare @.errorcode int
select * from abc
SET @.errorcode = @.@.error
--writing log
insert adaten.dbo.loghist(logdatum,loginfo,logfehler,saet ze)
values (getdate(),'test',@.errorcode,25)
The table "abc" dont exist.
If I call the script
osql /E /n /ic:\test.sql (with or without /b) the insert anweisung
instruction wont be executed.
I want something like ON ERROR RESUME NEXT. Is this possible ?
Thanks
aaapaul|||Hi
You may want to try using EXEC for your select statement
declare @.errorcode int
EXEC ('select * from abc')
SET @.errorcode = @.@.error
--writing log
insert adaten.dbo.loghist(logdatum,loginfo,logfehler,saet ze)
values (getdate(),'test',@.errorcode,25)
John
<lvpaul@.gmx.net> wrote in message
news:1128491173.083475.231000@.o13g2000cwo.googlegr oups.com...
Thanks, but it doesnt work
This is my script - its a file c:\test.sql
declare @.errorcode int
select * from abc
SET @.errorcode = @.@.error
--writing log
insert adaten.dbo.loghist(logdatum,loginfo,logfehler,saet ze)
values (getdate(),'test',@.errorcode,25)
The table "abc" dont exist.
If I call the script
osql /E /n /ic:\test.sql (with or without /b) the insert anweisung
instruction wont be executed.
I want something like ON ERROR RESUME NEXT. Is this possible ?
Thanks
aaapaul
No comments:
Post a Comment