sp_executesql 两种写法

写法1:

AlTER PROCEDURE TryAgain
@ReturnValue int output    
AS
declare @aa nvarchar(1000),
        @ForumID int,
        @count int,
        @TotalRecords int
BEGIN
set @ForumID =1    
set @aa=Nselect  @ReturnValue=count(1) from TC_BBS_Topics tc_bt where ForumID=+convert(varchar(10),@ForumID)
EXEC sp_executesql @aa,N@ReturnValue int output ,@ReturnValue   output

END

写法2:

AlTER PROCEDURE TryAgain
@ReturnValue int output    
AS
declare @aa nvarchar(1000),
        @ForumID int,
        @count int
BEGIN
set @ForumID =1    ;

set @aa=Nselect  @count=count(1) from TC_BBS_Topics tc_bt where ForumID=@id;

EXEC sp_executesql @aa,N@id int,@count int output ,@id = @ForumID, @count=@ReturnValue   output;

END

 

sp_executesql 两种写法,布布扣,bubuko.com

sp_executesql 两种写法

上一篇:[数据库]ROW_NUMBER() OVER函数的基本用法


下一篇:七夕献礼---Mysql密码修改步骤(图)