Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlt
Starting Member
1 Post |
Posted - 2009-04-26 : 12:51:19
|
| Hello,I have the id of a person.That id is primary key of 3 tables and only one table has that id.How do i know which table has the id without query'ing the 3 tables?Thanks in advance |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-04-26 : 13:31:49
|
| You can't, you'd have to query the tables. You can't know what's in a table without querying it. |
 |
|
|
aprichard
Yak Posting Veteran
62 Posts |
Posted - 2009-04-27 : 07:28:32
|
| Hi,SELECT Name FROM SYS.TABLES WHERE Object_ID =(SELECT Object_ID FROM SYS.COLUMNS WHERE Name='a')By using above query, You can get the tables that consist of 'a' Column. |
 |
|
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2009-04-27 : 07:38:04
|
| Adding to the aprichard result,you can also use the below SQLselect * from Information_Schema.columns where column_name like 'a'http://www.sqlserver007.com |
 |
|
|
|
|
|