Do an if statement for each of the 3 comparisons that would be passed in as
a second param.
 

.........................
Stephen Russell - Senior Developer
Mimeo Program Management Office
3350 Miac Cove Memphis, TN 38118
T: 901 566 5670  |  C: 901 246-0159  |  F: 901 566 8911
24/7 Customer Care: 1.800.GoMimeo
www.mimeo.com <http://www.mimeo.com/> 

-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Alex
Sent: Friday, October 10, 2008 9:23 AM
To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting
Subject: [DotNetDevelopment] Dynamically setting Where statement with
Conditionals in TSQL


Hello,

I'm writing a stored procedure in MS SQL 2005 with guts similar to
this:
Select *
>From Table1
Where Value > 1000

...but I need the '> 1000' part to be passed in as a parameter, so having it
something simliar to this is what I'm trying to do (which I know is invalid
syntax as written):
Declare @inStatement varchar(20)
Set @inStatement = '> 1000'
Select *
>From Table1
Where Value @inStatement

I could use a case statement to evaluate only the value '1000', but is there
anyway to use a Case or If statement to set the equality and second compared
column '> 1000' short of creating a dynamic SQL statement and using
sp_executesql?  I'd rather not go that route if I can help it.

Thanks --

Alex





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/DotNetDevelopment

You may subscribe to group Feeds using a RSS Feed Reader to stay upto date 
using following url  

<a href="http://feeds.feedburner.com/DotNetDevelopment";> 
http://feeds.feedburner.com/DotNetDevelopment</a>
-~----------~----~----~----~------~----~------~--~---

Reply via email to