如何在Sql StoredProceddure中编写if!= IsNull

时间:2017-04-01 10:07:59

标签: stored-procedures

这里我写了一个小的StoredProcedure当Id不可用它显示Else 请帮助

Alter procedure Sp_GetEmpById
(@Id int)
As
Begin
if(@Id!==ISNULL){
select Email,Gen,Country from Employee where Emp_Id =@Id
}
Else
print 'The Id Enter By u is Not  Availabe '+@Id
End

这里我在ISNULL和Then Id Enter By u is Not in Availabe '+@Id @Id

得到两个错误

1 个答案:

答案 0 :(得分:0)

这将编译,但我不确定您的要求:

create procedure Sp_GetEmpById @Id int
as
begin
if @Id is not NULL
    select Email,Gen,Country from Employee where Emp_Id = @Id
else
    print 'The Id Enter By u is Not  Availabe ' + @Id

end