Hello. Running SQL 2008.
I have the following sample data:
create table #temp (irecordid int, name varchar(100))
insert into #temp values (2373691, 'HURT, CYNTHIA')
insert into #temp values (2373691 , 'HURT, STEVEN')
insert into #temp values (2378322 , 'SUNSET CUSTOM HOMES, ')
insert into #temp values (2378322 , 'TORRES, NOE')
insert into #temp values (2378322 , 'NOE TORRES INC, ')
insert into #temp values (2373827, 'MILLER, BEVERLY')
insert into #temp values (2373827, 'MILLER, RONNIE')
I'm hoping to get a single result of the irecordid and a hash of all of the 'name' entries for each irecordid. For example:
Irecordid HASH
2373691 0x42DDD2300DAB2A93AC7DDF64FF479ECD
2378322 0x0D517BF2056B62FFA116A27B53D3B31D
2373827 0xDB2D7575E3A72E028DF0F8DF8EFF8933
I can get the results one at a time with the following query:
However, I'd like to get this with one script for my entire table. I have tried with grouping, but just can't get my syntax correct.
Any suggestions?
Thanks!
Brian
I have the following sample data:
create table #temp (irecordid int, name varchar(100))
insert into #temp values (2373691, 'HURT, CYNTHIA')
insert into #temp values (2373691 , 'HURT, STEVEN')
insert into #temp values (2378322 , 'SUNSET CUSTOM HOMES, ')
insert into #temp values (2378322 , 'TORRES, NOE')
insert into #temp values (2378322 , 'NOE TORRES INC, ')
insert into #temp values (2373827, 'MILLER, BEVERLY')
insert into #temp values (2373827, 'MILLER, RONNIE')
I'm hoping to get a single result of the irecordid and a hash of all of the 'name' entries for each irecordid. For example:
Irecordid HASH
2373691 0x42DDD2300DAB2A93AC7DDF64FF479ECD
2378322 0x0D517BF2056B62FFA116A27B53D3B31D
2373827 0xDB2D7575E3A72E028DF0F8DF8EFF8933
I can get the results one at a time with the following query:
Code:
select distinct irecordid, HASHBYTES('md5', CONVERT(varbinary(max), (select name from #temp where irecordid = 2373827 for xml auto )))
from #temp
where irecordid = 2373827
However, I'd like to get this with one script for my entire table. I have tried with grouping, but just can't get my syntax correct.
Any suggestions?
Thanks!
Brian