參數間掉了逗號:
Create Procedure GetAdd
@InAddress varchar(30) output,
@OutCount int output
AS
Select @OutCount = Count(*) From [news] where title=@InAddress
Go
Create Procedure GetAdd
@InAddress varchar(30) output,
@OutCount int output
AS
Select @OutCount = Count(*) From [news] where title=@InAddress
Go
@InAddress varchar(30) output
@OutCount int output
AS
declare @sql
select @sql='Select'+ @OutCount+' = Count(*) From [news] where title='+@InAddress
exec sp_executesql @sql,N'declare @InAddress varchar(30) ',@InAddress out
Go
你可以多声明一个变量,把输入变量放进去,然后传出这个变量就可以了。
Create Procedure GetAdd
@InAddress varchar(30),
@InAddres varchar(30) output,
@OutCount int output
AS
select @InAddres=@InAddress
Select @OutCount = Count(*) From [news] where title=@InAddress
Go试一试!
--建立存储过程
use pubs
go
Create Procedure GetAdd
@InAddress varchar(30),
@OutCount int output,
@OutCount2 int output
AS
Select @OutCount = Count(*) From [authors] where [au_lname]= @InAddress
Select @OutCount2= @OutCount+1
Go--执行存储过程
declare @a int
declare @b int
exec getadd @InAddress='White',@OutCount=@a output,@OutCount2=@b output
print @a
print @b--删除存储过程
drop procedure GetAdd