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 2005 Forums
 Transact-SQL (2005)
 Looping through DB Schema

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2010-01-07 : 09:55:34
I am trying to loop through all tables in my db and identify those tables which have a State_ column.

Can someone help me out with the SQL needed to perform this?

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-07 : 10:00:00
no need of loop. just use


SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE 'State_%'
Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2010-01-07 : 10:01:53
Visakh16:

Once again, thanks for the quick response!

Qman
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-07 : 10:02:13
Welcome
Go to Top of Page
   

- Advertisement -