我有一個像下面如何在sql server 2008中聲明時使用光標條件?
Declare Cur_1 cursor for
if @EmployeeId <> is not null
begin
select EmployeeID from tbl_Employee where EEmployeeStatus='Active' and EmployeeID = @EmployeeId
end
else
begin
select EmployeeID from tbl_Employee where EEmployeeStatus='Active'
end
Open Cur_1
Fetch next from Cur_1 into @EmpId
While @@FETCH_STATUS=0
Begin
end
Close Cur_1
deallocate Cur_1
查詢,但它不工作。它顯示我的語法錯誤。
它顯示語法錯誤,如果條件..
請幫我.......
'如果@EmployeeID不null',就沒有必要對<> – Zeina