CREATE PROCEDURE Vnet_SelectVideo
@vname nvarchar(20),
@videoID bigint = 1 output
AS
SELECT videoID FROM Vnet_Video WHERE vname=@vname
GO
这样的话查询分析器里能返回受影响的VIDEOID。。但不知道怎么取,最后还是0
CREATE PROCEDURE Vnet_SelectVideo
@vname nvarchar(20),
@videoID bigint = 1 output
AS
SELECT videoID FROM Vnet_Video WHERE vname=@vname
GO
这样的话查询分析器里能返回受影响的VIDEOID。。但不知道怎么取,最后还是0
CREATE PROCEDURE Vnet_SelectVideo
@vname nvarchar(20),
@videoID bigint = 1 output
AS
if exists(SELECT @videoID=videoID FROM Vnet_Video WHERE vname=@vname) then
return @videoID
else
return 0
GO
CREATE PROCEDURE Vnet_SelectVideo
@vname nvarchar(20) ,
@videoID bigint = 1 output
AS
if exists(SELECT * FROM Vnet_Video WHERE vname=@vname)
begin
SELECT @videoID=videoID FROM Vnet_Video WHERE vname=@vname
print @videoID
end
else
begin
print '没有找到相关记录'
end
GO
有exists的查询条件,select 后面只能跟*号,不然会出错