SQL Server Trace file create unique identifier for field TextData of type NTEXT -
to analyse imported trace file have unique value select distinct textdata myimportedtracefile
i tried using hashbyte although not sure if md5
right tool create unique identifier. if case (please tell me if so) still have problem
- using
hashbytes('md5', cast(textdata varchar(7999))) textdata_hashbytes
cuts few rows of (see reply)
what can create unique identifier every unique value (select distinct textdata ..
) in column textdata
?
update
based on post dan created testcase
drop table #temp create table #temp ( int, b ntext ) insert #temp ( a, b) select 1, 'some space' union select 2, ' space' union select 3, ' space ' union select 4, 'some space ' union select 5, ' space ' union select 6, ' space ' -- returns 6 rows select hashbytes('md5', cast(b nvarchar(max))) , cast(b nvarchar(max)) b #temp; -- returns 3 rows select newid() uniqueid, b ( select distinct cast(b nvarchar(max)) b #temp ) sq
these 3 rows result
' space ' -- 2sp b + 1sp e --> row 5 ' space' -- 1sp b + 0sp e --> row 2 'some space ' -- 0sp b + 3sp e --> row 4
it unclear how row 1 (0sp), 3 (1sp b+e) , 6 (2sp b+e) handled. whitespace removed other not.
you use derived table select distinct
:
select newid() uniqueid, textdata ( select distinct cast(textdata nvarchar(max)) textdata myimportedtracefile ) uniquequeries;
Comments
Post a Comment