Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-21
3
Medium Priority
?
444 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 200 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 1800 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

718 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