0

I am trying to execute this

CREATE CERTIFICATE [MyCert] FROM BINARY = 0x3082026 ...

It works fine on Sql Server 2014 onwards but on Sql Server 2012, I get a syntax error

Incorrect syntax near '=' Expecting FILE, ID or QUOTED_ID

Manuals appear to suggest it should be ok - unless I'm misunderstanding.

BINARY = asn_encoded_certificate
ASN encoded certificate bytes specified as a binary constant.
Applies to: SQL Server 2012 (11.x) and later.

I am using 11.0.7507.2.

I have also tried EXECing it as dynamic sql and get the same issue.

EDIT:

I installed a new instance of Sql Server 2012 (11.0.7001.0) and created a new database and ran the script against that, and it worked fine.

I had wondered whether because there were other databases with lower compat on the original 2012 server, there was a "lowest common denom" as to which sql parser was being invoked. But no! I also restored a compat level 90 db onto the new server and my original script still worked.

Simon Woods
  • 905
  • 1
  • 6
  • 13
  • Is your database compatibility level 110? – Dan Guzman Feb 17 '21 at 17:24
  • @Dan Guzman .... Yep – Simon Woods Feb 17 '21 at 17:30
  • Maybe the syntax error is due to another clause not included in the question snippet. Check [this answer](https://stackoverflow.com/questions/66200311/execute-a-trigger-always-with-sa-user/66200673#66200673) for a reference script that works on by SQL 2012 11.0.7493.4 machine. – Dan Guzman Feb 17 '21 at 18:11
  • Do the private_key_bits only contain expected hex characters, i.e.: `0x[0-9a-fA-f]+`? Is it one single token with no spaces and no line breaks? – AlwaysLearning Feb 17 '21 at 21:53

0 Answers0