|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, February 28, 2013 10:51 PM
Points: 42,
Visits: 133
|
|
Hi
I need list of all columns in the database along with a flag or what ever which should indicate whether it is a key(foreign key) or not. Can any one please help on this
/******************************************************** Technology is just a tool,in terms of getting the kids working together and motivating them,the teacher is the most important. ********************************************************/
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, February 28, 2013 1:54 AM
Points: 1,325,
Visits: 1,376
|
|
Hello,
You could probably build a formatted report using this code snippet as the starting point:-
Select * From sys.columns SC Left Join sys.foreign_key_columns FKC On (FKC.parent_object_id = SC.object_id) And (FKC.parent_column_id = SC.column_id)
Regards,
John Marsh
www.sql.lu SQL Server Luxembourg User Group
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, February 28, 2013 10:51 PM
Points: 42,
Visits: 133
|
|
Thanq john actually i am sarching for any buit in function or view for this any ways thnq for the reply
/******************************************************** Technology is just a tool,in terms of getting the kids working together and motivating them,the teacher is the most important. ********************************************************/
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:28 PM
Points: 37,730,
Visits: 29,996
|
|
grngarlapati (3/7/2009) Thanq john actually i am sarching for any buit in function or view for this any ways thnq for the reply
The views that John used in his query are built-in system views. There's no view of function that, by itself, will give you what you want, you'll have to build a query up using sys.columns and sys.foreign_key_columns.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|