Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing a field from a SQL
Message
 
 
À
04/03/2008 21:47:04
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01298743
Message ID:
01298758
Vues:
19
This message has been marked as the solution to the initial question of the thread.
>What I mean is that I am executing a SQL against the INFORMATION_SCHEMA.KEY_USAGE object. It extracts the constraint column name of the table I am passing in the WHERE clause. So, once the SQL is executed, how can I use that field? The field name in the SQL is Constraint_Name.
DECLARE @CONSTRAINT_NAME nvarchar(128)

SELECT @CONSTRAINT_NAME = CONSTRAINT_NAME
  FROM INFORMATION_SCHEMA.KEY_USAGE   
  WHERE ...

DECLARE @sql varchar(4000) 
SET @sql = 'ALTER TABLE DROP CONSTRAINT ' + @CONSTRAINT_NAME 
EXECUTE (@sql)
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform