sql server 2008 - find which tables contain specific text -
i have database has few hundred tables
i need find specific string in of columns in of tables.
how approach problem>??
to find table columns use:
select table_name=sysobjects.name, column_name=syscolumns.name sysobjects join syscolumns on sysobjects.id = syscolumns.id join systypes on syscolumns.xtype=systypes.xtype sysobjects.xtype='u' order sysobjects.name,syscolumns.colid
if want data in tables use dynamic sql can on these lines:
declare @sql varchar(100) declare @temp table (ind int, tablename nvarchar(100)) insert @temp select row_number() over(order [name]), [name] ( select [name] sys.tables ) d declare @index int set @index = 1 while @index < (select count(*) @temp) begin set @sql = ' select * ' + (select tablename @temp ind = @index) exec (@sql) set @index = @index + 1 end
Comments
Post a Comment