duchovnick
Programmer
hi,
i send 2 parameters to my procedure: one for identification (flag), the other is a file's name.
I want my procedure to operate a "select" querry including a "where" statement based on those parameters.
my code is:
and the error message says:
Thanks.
i send 2 parameters to my procedure: one for identification (flag), the other is a file's name.
I want my procedure to operate a "select" querry including a "where" statement based on those parameters.
my code is:
Code:
/*exec dbo.Dynamic '1','march_3_07'*/
alter PROCEDURE dbo.Dynamic @myparam VARCHAR(20),
@tab_name VARCHAR(20)
AS
BEGIN TRANSACTION
DECLARE @dynSQL VARCHAR(2000)
SET @dynSQL =
'
SELECT city
FROM
['+@tab_name+']
WHERE
CASE '+@myparam+'
city=''aaa'' AND
city<>''bbb''
end
'
exec (@dynSQL)
COMMIT
can anyone help me to correct the "where" statement ?Server: Msg 170, Level 15, State 1, Line 8
Line 8: Incorrect syntax near 'city'.
Thanks.