Home > database >  To find the location of the GUID values in the database
To find the location of the GUID values in the database

Time:01-01

The cause of the problem is that many database design now like to use the GUID, because this data is globally unique, not repeated, but too much trouble to understand and analysis of the application of, for example, the data table has a field: MemberStatus, references GUID data in the field are:
F9E42E1E - 01 e2-4831 - B34E - D55E0A405855
3914 fdef - 9 the ECB - 45 ea - b44e - 47 c1a48ea41e
F9E42E1E - 01 e2-4831 - B34E - D55E0A405855
3914 fdef - 9 the ECB - 45 ea - b44e - 47 c1a48ea41e
F9E42E1E - 01 e2-4831 - B34E - D55E0A405855
The practical significance of the corresponding data in the data described in another table, which tables don't know, also is not easy to find, is there a way that can be used to GUID the value of the lookup in the the entire database, and then get the result:
Find F9E42E1E - 01 e2-4831 - B34E - D55E0A405855 values in the following form and the number of occurrences of the
1: table 1, 6 fields a,
2: table 1, field b, 1
3: table 2, field c, 20 times
Table 4:3, field d, 3
.
So it is easy to understand, there once, is most likely to define the data meaningful form!
If you have the plan to solve the problem, please inform me trouble, thank you!

CodePudding user response:

"Which table don't know, also is not easy to find"
- & gt; Recommend contact system developers or please provide the data dictionary.

CodePudding user response:

, analysis the counterpart database, unable to contact the developer,

CodePudding user response:

 

/*
Test:
The Exec sp_search 'F9E42E1E - 01 e2-4831 - B34E - D55E0A405855'
Thinking:
Query out all table all fields of the GUID type first, and then statistical field value equal to the number of the @ Val, if greater than zero, save the results
If large amount of data, a bit slower
If you the value of the deposit, there may be other types of that you want system_Type_ID=36 to change it, so that more slow slow slow
*/

CREATE Procedure sp_Search (@ Val UNIQUEIDENTIFIER)
As
The Begin
Declare @ TBName Varchar (200)
Declare @ ColName Varchar (200)
Declare @ Rst int
Declare @ Sql NVarchar (4000)
Declare @ TB Table (TbName Varchar (200), ColName Varchar (200), Cnt INT)

Declare myCur Cursor For
The Select A.N ame, B.N ame From sys. Objects A Inner join sys. Columns B on a.o bject_id=b.o bject_id
Where A.T ype='U' And system_Type_ID=36

The Open myCur;

The Fetch Next From myCur Into @ TBName, @ ColName
While @ @ FETCH_STATUS=0
The BEGIN
The SET @ Rst=0
Set @ Sql='Select @ Rst=count (1) the From [' + @ TBName +] Where [' + @ ColName +]=@ Val)'
The Exec sp_Executesql @ SQL, N '@ Val UNIQUEIDENTIFIER, @ Rst int the output', @ Val, @ Rst output
If (@ Rst>
=1)Insert Into @ TB values (@ TBName, @ ColName, @ Rst)
The Fetch Next From myCur Into @ TBName, @ ColName
End
The Close myCur
DeAllocate myCur

Select * From @ TB
End


  • Related