我创建了一个存储过程来根据传递给参数的某些值检索一些详细信息。这需要在存储过程执行的 SQL 之间进行切换。以下是代码:
USE [DFS]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DAFS]
@EmailID Nvarchar(128),
@clientID int,
@userType Varchar(50),
@Success numeric output,
@msg varchar(100) output
AS
BEGIN
if @userType='Normal User'
IF EXISTS (SELECT 1 FROM dbo.Allcdn
WHERE EmailID = @EmailID AND ClientID = @clientID)
begin
set @Success=0
set @msg='Carry on ....'
end
else
begin
set @Success=6
set @msg='Not allowed ...'
END
end
else
Begin
IF EXISTS (SELECT 1 FROM dbo.Alcon
WHERE EmailID = @EmailID AND ClientID = @clientID)
BEGIN
set @Success=0
set @msg='Carry on...'
END
END
End
end
END
整个处理基于变量@userType。不知道为什么存储过程没有编译。