当存储过程开始时,我设置为set nocount on
1.如果我在这个存储过程中调用其他存储过程,在这个被调用的存储过程中未设置为on,此时被调用的存储过程将采用on还是off的状态执行?
2.如果当中有语句会触发到表的触发器的执行,那么该触发器的执行又是采用on还是off的状态执行?create procedure up123
(@num bigint)
as
begin
set nocount on exec up2 --执行被调用存储过程 , 是on ,还是 off?
update t1 set num = @num where num<>@num -- 若触发了t1的触发器,那么触发器的内容是on , 还是off的状态执行?
set nocount off
end
1.如果我在这个存储过程中调用其他存储过程,在这个被调用的存储过程中未设置为on,此时被调用的存储过程将采用on还是off的状态执行?
2.如果当中有语句会触发到表的触发器的执行,那么该触发器的执行又是采用on还是off的状态执行?create procedure up123
(@num bigint)
as
begin
set nocount on exec up2 --执行被调用存储过程 , 是on ,还是 off?
update t1 set num = @num where num<>@num -- 若触发了t1的触发器,那么触发器的内容是on , 还是off的状态执行?
set nocount off
end
存储过程可以看成运行在会话中的一个批(batch),在过程中设置的 nocount 在过程执行后是不会自动还原为原来的值。也就是说,在过程中 set nocount on,过程执行完毕后会话仍然是 set nocount on。
SQL code
-- 关闭会话的 nocount
set nocount off;
create procedure #p
as
set nocount on;
go
-- 执行过程
exec #p;
-- 验证会话的 nocount
dbcc useroptions;
/*
nocount SET
*/