Ask Paula!

...bringing you notes from the field...
posts - 117 , comments - 87 , trackbacks - 0

My Links

News

Copyright © 2008-2014 Paula DiTallo

Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

.NET Development

Enterprise Integration

Entertainment - Games

Java Development

Mobile/PDA Development

Professional Affiliations

In SQL Server, How Do I List all the Constraints by Table or by Column Name?

This one will order the contraints by table:

 

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]
order by Tab.[Name]

 

This one will order the contraints by column:

 

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]
order by Col.[Name]

Print | posted on Friday, November 5, 2010 11:36 AM | Filed Under [ Practical Answers SQL ]

Feedback

Gravatar

# re: In SQL Server, How Do I List all the Constraints by Table or by Column Name?

Thanks a lot.. your post helped me alot.. :)

Thank you so much..
9/17/2013 6:55 AM | kishore
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 
 

Powered by: