Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored Procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-18 : 09:43:51
Manu writes "I am trying to write a stored procedure in MS SQL Server. One of the arguments I pass in is an '@operator'(which could be '=', '!=', '<' or '>'). On the basis of this operator I have to write the where clause. Sort of like this

SELECT * FROM EMPLOYEE WHERE payscale '@operator' 25.
So if I pass in the argument '=' as @operator it should give me
SELECT * FROM EMPLOYEE WHERE payscale = 25.

I tried using case statement. It did not work:
SELECT * FROM EMPLOYEE WHERE pay
case @operator
when '=' then =
when '!=' then !=
end case
25

PLEASE HELP
THanks
Manu"

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-04-18 : 09:43:51
Please read the FAQ. Look for the section on dynamic SQL.
Go to Top of Page
   

- Advertisement -