Troubleshoot mscrm grabbing trace errors useful SQL script code

Source: Internet
Author: User
Tags rtrim

We usually use the trace captured by crmdiagtool4 released by Microsoft to troubleshoot errors. We can use the following SQL script code to find out which object the guid in the trace comes from, so as to help us quickly solve the problem.

/* This script will be slow to run and is a 2 step process but functionality exists */
/* Compile enhancements cocould 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
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.