Query is to view all constraints of the table in SQL Server.
SELECT * FROM (
Select SysObjects.[Name] As [Contraint Name] ,Tab.[Name] as [Table Name],Col.[Name] As [Column Name]
From SysObjects Inner Join (Select [Name],[ID] From SysObjects Where XType = 'U') As 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]
) A WHERE A.[TABLE NAME]='TABLENAME'
Thanks,
Siddu
P Please consider the environment before printing this e-mail
No comments:
Post a Comment