Hi,
I am new to sql(sql server 2000). I am writing a stored procedure which has two parameters
1)@Dist as int
2)@QC as bit.
I want to select from a perticular table based on the parameter value.
while I am using this statement..
if @QC = 0
insert into #Students select * from Students
else
insert into #Students select * from Students_QC
It gives me following error...
Server: Msg 137, Level 15, State 2, Line 3
Must declare the variable '@QC'.
Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'else'.
Server: Msg 137, Level 15, State 1, Line 61
Must declare the variable '@Dist'.
I can not determine what is wrong. Can anybody suggest a correct way to do this?
Thanks in advance,
ndp
I am new to sql(sql server 2000). I am writing a stored procedure which has two parameters
1)@Dist as int
2)@QC as bit.
I want to select from a perticular table based on the parameter value.
while I am using this statement..
if @QC = 0
insert into #Students select * from Students
else
insert into #Students select * from Students_QC
It gives me following error...
Server: Msg 137, Level 15, State 2, Line 3
Must declare the variable '@QC'.
Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'else'.
Server: Msg 137, Level 15, State 1, Line 61
Must declare the variable '@Dist'.
I can not determine what is wrong. Can anybody suggest a correct way to do this?
Thanks in advance,
ndp