0

Which of these 2 queries is preferred and why?

DECLARE
   @Value1 varchar(16) = 'hello'
  ,@Value2 varchar(16) = 'Hello'
  ,@a int = 0

IF CONVERT(VARBINARY(MAX), @Value1) = CONVERT(VARBINARY(MAX), @Value2)
  SET @a = 1;

IF @Value1 = @Value2 collate  Latin1_General_CS_AI
  SET @a = 2;
Gregbert
  • 121
  • 1
  • 11
  • 2
    I would use the second option as it does not require a conversion to a different datatype and would give you more control over what you want to allow or disallow as differences – Tom Jul 23 '15 at 20:44
  • Tom, Thank you for your answer. I'd select your response as the answer but there is no button to do so. I'm a newbie here so am I missing something? Thanks. – Gregbert Jul 27 '15 at 17:07

0 Answers0