我们平时运用微软发布的CrmDiagTool4抓取的Trace来排查错误,可以通过下面的SQL脚本代码来找出Trace中的Guid来源于哪个实体,以帮助我们快速的解决问题的所在。
/* This script will be slow to run and is a 2 step process but functionality exists */
/* Many enhancements could be made to make this a better script, time allowing */
/* */
/* Finds a string value in all tables and replaces it with another string */
/* Date Created: 9/30/2003 CVA */
declare @TableName char(256)
declare @ColumnName char(256)
declare @FindString char(256)
declare @sql char(8000)
/*Replace X with character(s) you which to find and Y with its replacement*/
set @FindString = '{5e90da7d-51d8-4d8c-9582-eead2b43b0d6}'
/*select o.name, c.name from syscolumns c inner join sysobjects o
on o.id = c.id
where o.xtype = 'U'*/
declare T_cursor cursor for
select o.name, c.name from sysobjects o inner join syscolumns c
on o.id = c.id
where o.xtype = 'U' and c.xtype in (36) --for GUID
open T_cursor
fetch next from T_cursor into @TableName, @ColumnName
while (@@fetch_status <> -1)
begin
set @sql = 'if exists (select * from [' + rtrim(@TableName) + '] where ' + rtrim(@ColumnName) + ' = ''' + rtrim(@FindString) + ''')
begin
print ''Table = ' + rtrim(@TableName) + ' Column = ' + rtrim(@ColumnName) + '''
end'
--print @sql
exec(@sql)
fetch next from T_cursor into @TableName, @ColumnName
end
close T_cursor
deallocate T_cursor
浙公网安备 33010602011771号