Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Expresions inside where clause
Message
From
24/08/1999 12:30:11
 
 
To
24/08/1999 11:21:45
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00257084
Message ID:
00257150
Views:
20
Yes, you can implement this type of behavior using Dynamic SQL. An example would be something like this:

CREATE PROCEDURE customers_browse
@condition varchar(1000)
AS
DECLARE @sql varchar(1000)
SET @sql = 'SELECT * FROM customers WHERE ' + @condition
EXECUTE (@sql)


There are a couple of this that you should be aware of. The Dynamic SQL exists within it own batch so any temporary table that is created will be released when the EXECUTE completes. Also, the Dynamic SQL cannot reference any variables that exist outside the Dynamic SQL. You should read the Execute topic in the SQL Server Books Online.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Reply
Map
View

Click here to load this message in the networking platform