Ask Paula!

...bringing you notes from the field...

  Home  |   Contact  |   Syndication    |   Login
  121 Posts | 5 Stories | 94 Comments | 0 Trackbacks

News

Copyright © 2008-2015 Paula DiTallo

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

.NET Development

Enterprise Integration

Entertainment - Games

Java Development

Mobile/PDA Development

Professional Affiliations

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]

posted on Friday, November 5, 2010 11:36 AM

Feedback

# re: In SQL Server, How Do I List all the Constraints by Table or by Column Name? 9/17/2013 6:55 AM kishore
Thanks a lot.. your post helped me alot.. :)

Thank you so much..

Post A Comment
Title:
Name:
Email:
Comment:
Verification: