如何在本机编译的存储过程中比较varchar参数?

时间:2016-02-17 14:41:46

标签: sql sql-server sql-server-2014 in-memory-database oltp

我正在将一些表和存储过程迁移到内存优化表和本机编译的存储过程。我陷入了字符串比较的困境。

  

比较,排序和操纵没有的字符串   本机编译存储不支持使用* _BIN2归类   程序

max()

1 个答案:

答案 0 :(得分:2)

在AdventureWorks2014的副本中,更改@SecretKey参数的排序规则似乎对我有用:

CREATE PROCEDURE [User].[GetFingerPrint]
    @Id int,
    @SecretKey VARCHAR(512) 
    WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AS BEGIN ATOMIC WITH
(
 TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english'
)

SELECT [Id]
      ,[FingerPrint]
      ,[SecretKey]
      ,[BranchId]
      ,[SteadySign]
      ,[CreatedOn]
      ,[ModifiedOn]
  FROM [User].[FingerPrints]
  WHERE [Id] = @Id AND [SecretKey] = @SecretKey COLLATE LATIN1_GENERAL_BIN2

END
GO