存储过程中的output应用

CREATE PROCEDURE EGA_DrugReg_CheckVerifyCode
(
@verifycode NVARCHAR(50),--校验码
@type NVARCHAR(10)--表类型,见下CASE块
@rid NVARCHAR(128) OUTPUT--如有相同校验码,输出ID,否则''
)
AS

set @rid=''
DECLARE @sql NVARCHAR(256)

IF CONVERT( INT ,@type ) > 4 AND CONVERT( INT , @type ) < 0
RETURN

SET @sql = 'SELECT '+@rid+'=ID FROM '
SET @sql = @sql +
CASE @type
WHEN '0' THEN'table0 '
WHEN '1' THEN 'table1 '
WHEN '2' THEN 'table2 '
WHEN '3' THEN 'table3 '
WHEN '4' THEN 'table4 '
END
SET @sql = @sql + 'WHERE F_VerifyCode = ''' + @verifycode + ''''
EXEC( @sql )

--exec sp_executesql(@sql, N'@rid nvarchar(128)',@rid = ''

select @rid

return
GO

你可能感兴趣的:(sql,F#,Go)