DECLARE @msg varchar(800)
SET @msg='ED5FF995-5EDA-4070-A2AC-A5580149A704' --要搜索的字符串
DECLARE @sql varchar(8000)
DECLARE Cursorzzb CURSOR LOCAL FOR
SELECT sql='IF EXISTS ( SELECT 1 FROM ['+o.name+'] WHERE ['+c.name+'] LIKE ''%'+@msg+'%'' ) PRINT ''表名+字段名:['+o.name+'].['+c.name+']'''
FROM syscolumns c JOIN sysobjects o ON c.id=o.id
--xusertype可以查select * from sys.types 175=char
WHERE o.xtype='U' AND c.status>=0 --AND c.xusertype IN ('36')
OPEN Cursorzzb
FETCH NEXT FROM Cursorzzb INTO @sql
WHILE @@FETCH_STATUS=0
BEGIN
EXEC(@sql)
FETCH NEXT FROM Cursorzzb INTO @sql
END
CLOSE Cursorzzb
SET @msg='ED5FF995-5EDA-4070-A2AC-A5580149A704' --要搜索的字符串
DECLARE @sql varchar(8000)
DECLARE Cursorzzb CURSOR LOCAL FOR
SELECT sql='IF EXISTS ( SELECT 1 FROM ['+o.name+'] WHERE ['+c.name+'] LIKE ''%'+@msg+'%'' ) PRINT ''表名+字段名:['+o.name+'].['+c.name+']'''
FROM syscolumns c JOIN sysobjects o ON c.id=o.id
--xusertype可以查select * from sys.types 175=char
WHERE o.xtype='U' AND c.status>=0 --AND c.xusertype IN ('36')
OPEN Cursorzzb
FETCH NEXT FROM Cursorzzb INTO @sql
WHILE @@FETCH_STATUS=0
BEGIN
EXEC(@sql)
FETCH NEXT FROM Cursorzzb INTO @sql
END
CLOSE Cursorzzb