【发布时间】:2015-01-19 18:16:09
【问题描述】:
我在批处理文件上调用 SQL Server 脚本,但我需要在批处理文件中得到错误(当脚本失败时),我该怎么办?
这是批处理文件:
sqlcmd -S HOST -U User -P password -i test.sql
echo %errorlevel%
这是脚本文件(Test.sql):
USE TrainingSitecore_Web
go
SELECT * FROM items
go
RAISERROR ('This is a test Error.',-- Message text.
16,-- Severity.
1 -- State.
);
有意义吗?
【问题讨论】:
-
以下链接中的最后一个答案是您的情况吗? dba.stackexchange.com/questions/77298/…
-
是的,伙计们,它正在工作:)
标签: sql-server batch-file error-handling sql-scripts