Solved

I also wanted to display the Tablecolumn name ?????? do not know how?

Posted on 2011-03-21
3
434 Views
Last Modified: 2012-05-11
SELECT  OBJECT_NAME(parent_object_id) AS DefinedInTable ,
        OBJECT_NAME(referenced_object_id) AS ReferenceTable ,
        OBJECT_NAME(????????) AS Tablecolumn ,
        name AS ForeignKeyName
FROM    sys.foreign_keys
WHERE   OBJECT_NAME(parent_object_id) = 'AceData' ;
0
Comment
Question by:goodk
3 Comments
 
LVL 10

Assisted Solution

by:khan_webguru
khan_webguru earned 50 total points
ID: 35182147
Hello Bro!

You can do this by any of following quires

 
SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name = 'THE_COLUMN_NAME' )

Open in new window


Or

 
SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name like '%PART_OF_NAME%' )

Open in new window


Or

 
SELECT  o.name, o.type_desc, p.name, t.name, p.max_length, p.precision, p.scale, 
        p.is_output, p.is_cursor_ref, p.has_default_value, p.is_xml_document, p.default_value
FROM    sys.all_objects o
        inner join sys.all_parameters p on o.object_id = p.object_id
        inner join sys.types t on p.user_type_id = t.user_type_id
order by o.type_desc, o.name, p.name

Open in new window


Or

 
SELECT column_name 'Column Name',
data_type 'Data Type'
FROM information_schema.columns
WHERE table_name = 'Address'

Open in new window



Or

 
select column_name, data_type, character_maximum_length from information_schema.columns
where table_name = 'myTable'

Open in new window



Or

 
EXEC sp_columns @table_name

LIKE

EXEC sp_columns "Employee"

Open in new window


I hope this will solve your problem

Regards,

Asif Ahmed Khan
0
 
LVL 3

Accepted Solution

by:
ssisworo earned 450 total points
ID: 35182330
Have you tried this :

SELECT  OBJECT_NAME(foreign_keys.parent_object_id) AS DefinedInTable ,
        OBJECT_NAME(foreign_keys.referenced_object_id) AS ReferenceTable ,
        COL_NAME(foreign_keys.referenced_object_id,foreign_key_columns.referenced_column_id ) AS ReferenceTablecolumn,
        COL_NAME(foreign_keys.parent_object_id,foreign_key_columns.parent_column_id ) AS DefinedTablecolumn,
        name AS ForeignKeyName
FROM    sys.foreign_keys, sys.foreign_key_columns
WHERE   OBJECT_NAME(foreign_keys.parent_object_id) = 'AceData' and
        foreign_keys.OBJECT_ID = foreign_key_columns.constraint_object_id;
0
 

Author Closing Comment

by:goodk
ID: 35185198
thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now