Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Expresions inside where clause
Message
De
24/08/1999 12:30:11
 
 
À
24/08/1999 11:21:45
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00257084
Message ID:
00257150
Vues:
21
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform