March 5, 2009 at 11:48 pm
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.
********************************************************/
March 6, 2009 at 1:30 am
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
March 7, 2009 at 9:53 pm
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.
********************************************************/
March 8, 2009 at 1:58 am
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, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply