Create certificate from binary - sql

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.

Related

SCADA reading from MariaDB: Error in Syntax

We have a SCADA System (Intouch). It had a Access .mdb database file on the client PC, which was defined as System DSN (Windows ODBC).
What I'm trying to do is to migrate the whole DB thing to MariaDB, running on remote server. I have already a running server, the connection from the SCADA PC to the server is up an running and it is added as system DSN in ODBC, using the MariaDB ODBC connector. I was also able to export all the data from Access to the Maria database, using Access's native export to ODBC database, so all my data is in Maria.
The Problem: The SCADA cannot read ot white anythig. In the scada's log i get SQL Syntax errors (forgot to mention, that the scada uses SQL). Thanks in advance!
Update:
It's old fashioned WindowMaker application, not Archestra, thus the SQL Functions are used. I've even changed the ODBC connector from Maria to mySQL
Today I've made some logs. Here the error:
"SELECT Checksum, (rest deletet by me.. is too long).... FROM Stp WHERE ProgNr=1and StpNr=0"
[37000] [MySQL][ODBC 8.0(a) Driver][mysqld-5.5.5-10.3.22-MariaDB]
You have an error in your SQL syntax; check the manual that corresponds
to your MariaDB server version for the right syntax to use near 'StpNr=0' at line 1 (1064)
From the review of your update it looks like its just a plain ol' syntax error.
What you provided:
SELECT Checksum, (etc)... FROM Stp WHERE ProgNr=1and StpNr=0
The logs complain of syntax by StpNr=0 but your problem is immediately before that where you haven't put a space between the AND and the ProgNr=1 command.
Correct syntax would be:
SELECT Checksum, (etc)... FROM Stp WHERE ProgNr=1 and StpNr=0
In my personal experience the WindowMaker SQL functions are extremely clunky to work with (especially with the 131 char limit on message tags). You can usually help yourself out by Logging your Query then trying it directly in your database.

Export from select Statement to JSON in SQL

I use Microsoft SQL Server Management Studio v17.2. I know that for exporting data to JSON must use method like this:
SELECT *
FROM table1
WHERE [conditions]
FOR JSON PATH, ROOT('root')
but when I use this code in SQL Server Management Studio, an error occurred:
Incorrect syntax near 'json'.
Please help me solve this error.
This doesn't have anything to do with Management Studio; the version of SSMS you're using is irrelevant. It has to do with the version of SQL Server you're running the code against, which is completely separate from the version of SSMS.
FOR JSON was introduced in SQL Server 2016. If you are not running 2016 or better (or Azure SQL Database), you'll need to upgrade, or use a different approach to get your data into JSON format.

SHA2_256 Hashbytes generating different value on SQL Server 2012 with different version

I am facing a weird problem, I have one source - SQL Server 2012 with version no. 10.5.1753.0 - where hashbyte SHA2_256 is generating a null value.
On the other hand, I have another source - SQL Server 2012 with version no. 11.0.3000.0 - where hashbyte SHA2_256 is generating some value.
I have to deal with this problem, where I can't put request to source owner to upgrade their version and still I need to pull records from this source.
Versionnumber 10.5.1753.0 belongs to SQL Server 2008 R2 and not 2012.
SHA256 is only supported in SQL Server 2012+.
(BTW 10.5.1753.0 is a pretty old version back from 2010 and 11.0.3000.0 is from 2012. They really should be updated.)

IF NOT EXIST option is not coming in SQL server 2012 while generating script file

Not getting "IF Not EXIST" option is not getting in sql server while generating script file. This option was present in sql server 2008 but not showing in 2012
While generating script file in SQL Server 2012 we can’t see the “IF NOT EXIST’ option , which was present in SQL Server 2008 to check the existence of the object. This feature is also present in 2012 but we have make true the option “Check for object existence” to get the same output as SQL Server 2008.

Can I create a view that will query a table from another sql server on another server but same domain

I need to query a table from another SQL Server on a different server but same domain, but I am not sure how I will be able to do it.
I tried solution given in this answer Can I create view in my database server from another database server but it doesn't work for me as I got SQL Server 2000 (please don't hate :-) ).
When I try solution given then i get this error,
Line 23: Incorrect syntax near '-'.
which is because command is not compatible with SQL Server 2000.
Edit
SELECT * FROM AnotherServer.AnotherServerDatabase.Server.Table1
you can link the servers and run cross server queries as long as you put the server name before the DB your running the query on.
For example
SELECT * FROM "linkedserver".dbo.aTable
(without "" marks )
bear in mind different server versions though. I run cross server queries from 2008 to 2000 servers and its a pain adapting :)