Solved

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

Posted on 2011-03-21
3
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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…

710 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