Hi everybody,
I need to declare a cursor but depending on the current day the select statement is different (the where condition actually is different).
declare cursorname cursor for
if @day = '1'
begin
select a, b, c from table where ...
end
if @day = '2'
begin
select a, b, c from table where ...
end
and I'm receiving the message: "Incorrect syntax near the keyword 'if'."
If the message is true, then how can I solve the problem?
Thx,
TMRO
I need to declare a cursor but depending on the current day the select statement is different (the where condition actually is different).
declare cursorname cursor for
if @day = '1'
begin
select a, b, c from table where ...
end
if @day = '2'
begin
select a, b, c from table where ...
end
and I'm receiving the message: "Incorrect syntax near the keyword 'if'."
If the message is true, then how can I solve the problem?
Thx,
TMRO