我们说我有这个程序
ALTER PROCEDURE CallsChange
@ID int,
@CS int
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO [ctlCalls] ([InsertDate])
VALUES (GETDATE())
UPDATE [ctlOrders]
SET [DeliverymanID] = NULL,
[CallId] = (SELECT SCOPE_IDENTITY()),
[CurrentStatus] = 1
WHERE ID = @ID
END
我想知道的是:如果有一个SQL Server变量返回值,如果更新后某些内容在数据库中发生了变化?换句话说:如果已成功运行更新
答案 0 :(得分:0)
您可以使用Print语句来检查命令是否已在过程中成功执行..
<强> EX:强>
create proc usp_test
as
begin
insert into t1
select 2
Print 'Insert completed'
update t
set id=1
print 'update completed'
end
答案 1 :(得分:0)
答案 2 :(得分:0)
试试这个:
ALTER PROCEDURE CallsChange
@ID int,
@CS int,
@Output varchar(10) = '' OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO [ctlCalls] ([InsertDate])
VALUES (GETDATE())
UPDATE [ctlOrders]
SET [DeliverymanID] = NULL,
[CallId] = (SELECT SCOPE_IDENTITY()),
[CurrentStatus] = 1
WHERE ID = @ID
SET @Output = @@ROWCOUNT
SELECT 'Updated ' + @Output + ' records'
END