SQLTeam.com | Weblogs | Forums

Join by id rather than VARBINARY

I work on sql server 2014
I need to get partc as expected result
Actualy i need partc from table #partsc that have Verification Hash on table #VervicationCode
are there are any way to get part c without join with Verification Hash

create table #partsc
 (
 partc int,
 [VerificationHash] VARBINARY(512) NULL 
 )
 insert into #partsc(partc,VerificationHash) 
 values
 (11234,0x566B391EDEB07A47B17B89265ABE19850655885D83247AE7E7C28849D8873A31F56D139E4987BFE85B476035E39B7308C5D203955A238F92D5A2096B50AD674C),
 (15431,0x5677965D16CEEDC754EAED74780662518E132F08C1B6CFF67BE62D21100C3B4C63E09937BB7153CDE67550F957AFBB23658B2193EB842FC173A8F8460DED246D),
 (67501,0x569132E995038072EA4AE52DC760FCB2C21AE1A6F047C66FF86B483BF575DE2EF412B3B10CDC8B8DC8B8D31D28BF90442C31811F13EC5B49DE1EBC008B6EEF16),
 (87190,0x56C5668A7FCB015D39EE602FAC80124050D0ADCA684D77FC99D7C293DCC09DA1A4FA2514F89E86D7619AE20A72C6CAE2A7BFE776F89C5494C36994C84241D705),
 (987610,0x56E0315397B4A932570101661B449FC41DF9683F5EDCC7387A8C9FA8E357A06FCF1989587CCF3E0548F79F36BB2F5C91BF6CD9E988EA9922C5C865A043B51B1F),
 (89871,0x57B1B8FF59BFE3F788AA1C6D5CFFC40D54F0D494D60B43CED1B52C1E290CC8AE62C3E1220365F1DCB0A00688AF92222DC32CC5454DCF9572812735D9FAF7E3C7),
 (12909,0x57DAFCAA14E6561FD8C2109627732DFDBEC5E169682080EF1107FA96ED505CC18BD22924BFA19A1A346BB15440FF48F53202A88672AD6FC66F4DAF0D518BC69C)
    
 create table #VervicationCode
 (
 [VerificationHash] VARBINARY(512) NULL 
 )
 insert into #VervicationCode(VerificationHash) 
 values
 (0x5677965D16CEEDC754EAED74780662518E132F08C1B6CFF67BE62D21100C3B4C63E09937BB7153CDE67550F957AFBB23658B2193EB842FC173A8F8460DED246D),
 (0x569132E995038072EA4AE52DC760FCB2C21AE1A6F047C66FF86B483BF575DE2EF412B3B10CDC8B8DC8B8D31D28BF90442C31811F13EC5B49DE1EBC008B6EEF16),
 (0x56C5668A7FCB015D39EE602FAC80124050D0ADCA684D77FC99D7C293DCC09DA1A4FA2514F89E86D7619AE20A72C6CAE2A7BFE776F89C5494C36994C84241D705),
 (0x56E0315397B4A932570101661B449FC41DF9683F5EDCC7387A8C9FA8E357A06FCF1989587CCF3E0548F79F36BB2F5C91BF6CD9E988EA9922C5C865A043B51B1F)

expected result will be :slight_smile:

partc
15431
67501
87190
987610

What have you tried . Also you have other questions that others have answered for you and you have not responsed to whether the answers worked or not. Least you can do is say thanks

without you reply thanks for response and answer

what i try is

select partc
from #partsc
where VerificationHash in(select VerificationHash
                          from #VervicationCode);

but i don't need this solution

and i need to generate id for two tables then join by id
so How to do that please ?

Why do you need to generate id?

i need to generate id because when join by all this text
(0x5677965D16CEEDC754EAED74780662518E132F08C1B6CFF67BE62D21100C3B4C63E09937BB7153CDE67550F957AFBB23658B2193EB842FC173A8F8460DED246D)
for big data will be sow
so if i generate id meaning it is integer or number
and that will be faster than join by verivication hash

What led you to the conclusion that it is slow joining by that column?