2017-04-01 65 views
0

在這裏,我寫了一個小的StoredProcedure當ID不使用它顯示否則 請Helpme如何撰寫如果!= ISNULL在SQL StoredProceddure

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

在這裏,我得到兩個錯誤在ISNULL而Then Id Enter By u is Not in Availabe '[email protected] @Id

+0

如果@id不爲空,但是這個ID不存在於'Employee'表中? –

回答

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