SQL Server'='比较器查询区分大小写

时间:2015-07-23 20:38:40

标签: sql-server-2008 collate

首选哪两个查询?为什么?

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;

0 个答案:

没有答案