DEFINITIONS

Definitions More Info.
Definition ID198
TitleSQL
CategorySCRIPT
DefinitionTUM DATABASE DE DATA-KELIME ARAMA
Definition Descriptionhttps://solutioncenter.apexsql.com/quickly-search-for-sql-database-data-and-objects-in-ssms/

DECLARE @SearchText varchar(500),
@SchemaName VARCHAR(500),
@Table varchar(500),
@ColumnName varchar(500),
@String varchar(500);
--modify the variable, specify the text to search for SET @SearchText = 'John';
SET @SearchText = 'adar'
DECLARE CursorSearch CURSOR FOR
SELECT TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
OPEN CursorSearch;
FETCH NEXT FROM CursorSearch INTO @SchemaName,@Table,@ColumnName;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'SU ANDA ARAMA YAPTIGI TABLO: '+@Table+' KOLON ADI: '+@ColumnName
SET @String = 'IF EXISTS (SELECT * FROM '
+@SchemaName+'.'
+ @Table
+ ' WITH(NOLOCK) WHERE '
+ @ColumnName
+ ' LIKE ''%'+ @SearchText+ '%'') PRINT ''BULUNAN KAYIT:'+ @Table+ ', '+ @ColumnName+ '''';
EXECUTE (@String);
FETCH NEXT FROM CursorSearch INTO @SchemaName,@Table,@ColumnName;
END;
CLOSE CursorSearch;
DEALLOCATE CursorSearch;
RecordBycunay
Record Date18-05-2012 11:54:00
Düzenle
Kopyala
Sil