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 |
|
JeffT
Posting Yak Master
111 Posts |
Posted - 2006-03-21 : 10:06:15
|
| Hi,I am trying to query for a common value in a column called "file_auth_nbr" in 30 different tables. I was going to try something like this (see below) but wasn't sure if this was the most efficient, fastest, or correct, way to get what I'm looking for:Select distinct a.file_auth_nbr from table1 as ajoin table2 as bon a.file_auth_nbr = b.file_auth_nbrjoin table3 as con a.file_auth_nbr = c.file_auth_nbrjoin table4 as don a.file_auth_nbr = d.file_auth_nbrjoin table5 as eon a.file_auth_nbr = e.file_auth_nbr......etc., etc. Any suggestions would be much appreciated,Jeff |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-03-21 : 10:54:55
|
| This could have a few problems if file_auth_nbr can occur multiple times in a table. You will end up with somthing similar to a cross join with a million bizillion rows in SQL Server's internal work tables.You should try to do it with a union query.CODO ERGO SUM |
 |
|
|
|
|
|