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 |
|
junaidKhan
Starting Member
3 Posts |
Posted - 2008-12-27 : 06:57:45
|
| HiI want to see whether 'someString' appears in the database.the database contains 100s of tables, and each tables contains 1000srows and many columns.for this I wnat to run 2 for loops, one for tables in the databseand another for columns in the tables.Ok, getting the columns is easy, but how can I get the tables collection in the database?any idea |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2008-12-27 : 07:35:26
|
| select * from sys.tables |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2008-12-27 : 07:56:56
|
| i think ur requirement, is to get a column name in a particular table in a databasetry this select table_name,column_name from information_Schema.columns where column_name like '%columnname%' |
 |
|
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-27 : 11:33:44
|
| or use undocumented procedures sp_msforeachdb and sp_msforeachtable |
 |
|
|
Skorch
Constraint Violating Yak Guru
300 Posts |
Posted - 2009-01-15 : 11:13:11
|
quote: Originally posted by visakh16 or use undocumented procedures sp_msforeachdb and sp_msforeachtable
Wow, thanks for those. I've never heard of them before and they seem very useful. There's a great writeup about them here:http://www.databasejournal.com/features/mssql/article.php/3441031/SQL-Server-Undocumented-Stored-Procedures-spMSforeachtable-and-spMSforeachdb.htm |
 |
|
|
Skorch
Constraint Violating Yak Guru
300 Posts |
Posted - 2009-01-15 : 11:14:25
|
| Oops, I didn't realize I bumped up an old thread. Sorry about that - I got carried away reading through some older stuff. |
 |
|
|
|
|
|