How do i find the table

Posted by Self-Innovator under Sql Server on 9/7/2012 | Points: 10 | Views : 927 | Status : [Member] | Replies : 2
Hi Everyone,
How do i find out the table from the database where i have only the record. From that record how can i dentify which table it will exist in. From the below query i can find out the table names is any possibilities to find out the tables based on records...
SELECT T.NAME AS TABLE_NAME,SCHEMA_NAME(SCHEMA_ID) AS SCHEMA_NAME,C.NAME AS COLUMN_NAME FROM SYS.tables AS T
INNER JOIN
SYS.columns as C ON T.object_id=C.object_id WHERE C.name LIKE 'gpi%'


Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Pandians on: 9/7/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Check It Out!
SELECT T.NAME AS TABLE_NAME,SCHEMA_NAME(SCHEMA_ID) AS SCHEMA_NAME,C.NAME AS COLUMN_NAME 

FROM SYS.tables AS T
JOIN SYS.columns as C ON T.object_id=C.object_id
JOin sys.sysindexes I On (I.id = T.object_id)
WHERE C.name LIKE 'gpi%'
And I.rowcnt >0


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 9/7/2012 [Member] Bronze | Points: 25

Up
0
Down
Pandian S
sysindexes table doesn't have the property id...any other soln

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response