Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing constraints
Message
De
25/03/2011 10:41:31
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01504936
Message ID:
01504985
Vues:
29
>I would use this:
>
>DECLARE @ConstraintName nvarchar(128)
>DECLARE @Command nvarchar(max)
>SET @Command = ''
>Select @Command = @Command + 
>       'ALTER TABLE '+tab.name+' DROP CONSTRAINT '+sysobjects.name+CHAR(13)+CHAR(10)
>FROM SysObjects
>INNER JOIN (Select [Name],[ID] From SysObjects Where XType = 'U')  Tab
>       ON Tab.[ID] = Sysobjects.[Parent_Obj] 
>Inner Join sysconstraints On sysconstraints.Constid = Sysobjects.[ID] 
>Inner Join SysColumns Col On Col.[ColID] = sysconstraints.[ColID] And Col.[ID] = Tab.[ID]
>
>EXEC sp_executesql @Command
>
>
>but that is a matter of preferences :-)
>
>In your case you could add a print @Command before executing each line to see where you get the error.

Thanks, this is much simpler.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform