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
 General SQL Server Forums
 New to SQL Server Programming
 search through each table in each db

Author  Topic 

rnbguy
Constraint Violating Yak Guru

293 Posts

Posted - 2007-01-03 : 22:52:19
has anyone figure out how to do this?

the closes ive come is this (found on google):

declare @sql nvarchar(4000)

set @sql = ''
select @sql = @sql + 'exec ' + name + '..sp_msforeachtable @command1='' print ''''use ' + name + ' select * from ^'''' '', @replacechar=''^''' + char(13)
from master..sysdatabases where dbid > 4
exec (@sql)


i want it to actually execute whats being printed? so that way i can search through each table in each database for something im after..

either way i dont think itll help

im trying to search all databases for a certain value... a personss name

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-03 : 23:56:26
Check out this link:
[url]http://weblogs.sqlteam.com/brettk/archive/2005/02/08/4144.aspx[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rnbguy
Constraint Violating Yak Guru

293 Posts

Posted - 2007-01-04 : 00:00:36
thanx heaps works perfect now ill just try modify it to run threw all dbs :)
Go to Top of Page

rnbguy
Constraint Violating Yak Guru

293 Posts

Posted - 2007-01-04 : 00:28:17
done. wohoo :)
Go to Top of Page
   

- Advertisement -