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
 Transact-SQL (2000)
 URGENT! Replace > with @Parameter value

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-03-19 : 09:30:03
Oliver writes "Greetings,

Basically, I have a stored procedure that accepts valus from an ASP app. The SP selects stuff based on these values (duh!)

Consider the following statement:
SELECT [FIELD] FROM [TABLE] WHERE [FIELD] > [VALUE]

I want to do the same thing, but instead of using the '>' operator, I want to use the value of a parameter, which will either be > or <

Something like this:
SELECT [FIELD] FROM [TABLE] WHERE [FIELD] @Operator [VALUE]"

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2007-03-19 : 09:30:03
Please see the FAQ for a link to a post on dynamic SQL.
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-03-19 : 13:51:11
if there are only two choices, I wouldn't use dynamic sql for this. just use an IF ... ELSE to control which query runs.


www.elsasoft.org
Go to Top of Page
   

- Advertisement -