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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Find column data

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-11-02 : 07:48:25
Roland writes "I have a query that will find all tables that have a specific column name. After I find the column how can I find specific data for that column?
Example:
I can find the column Order_Number in table_1,Table_3,table_7.
Now I want to see if a particular order is in 1 or all 3 of the tables.

Thanks for your time."

nr
SQLTeam MVY

12543 Posts

Posted - 2006-11-02 : 07:55:46
You will have to use dynamic sql if you don't want to code all the possibilities.

exec ('select * from ' + @mytbl + ' where ' + @mycol + ' = ' + @myorder)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-02 : 20:09:56
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm
http://www.sommarskog.se/dynamic_sql.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -