Solved

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

Posted on 2011-03-21
3
440 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

630 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