储存过程帮忙查错和优化
Create Procedure Out
@Url nvarchar(4000) Output
As
Declare @OutTemp Int
Declare @ID Int
--在System取出OutTemp值
Select @OutTemp = OutTemp From System
--在Users表中检索出比OutTemp大的一个ID,并返回@Url
Select Top 1 @Url = Url From Users Where ID > @OutTemp
Go
------解决方案--------------------Create Procedure Out
@Url nvarchar(4000) Output
As
Declare @OutTemp Int
Declare @ID Int
--在System取出OutTemp值
Select top 1 @OutTemp = OutTemp From System --或者加Where條件
--在Users表中检索出比OutTemp大的一个ID,并返回@Url
Select Top 1 @Url = Url From Users Where ID > @OutTemp
Go
------解决方案--------------------Create Procedure Out
@Url nvarchar(4000) Output
As
Select Top 1 @Url = Url
From Users
Where ID > (Select OutTemp From System) --从System取条件是否需要过滤??
Go
--执行是没有问题的
declare @u nvarchar(4000)
exec dbo.Out @u output
select @u