I am having an issue with the ISJSON function in Azure Synapse Dedicated SQL pool.
The code snippets below executes correctly in SQL Server 2016+
--test1
SELECT myJsonField
FROM myTable
WHERE ISJSON(myJsonField) = 1
--test2
SELECT ISJSON('{"a":1}')
but when I execute the same code on an Azure Synapse SQL Pool I get the following error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'.
According to the documentation, this function should be available in Synapse: https://learn.microsoft.com/en-us/sql/t-sql/functions/isjson-transact-sql?view=azure-sqldw-latest
Azure Synapse version:
SELECT ##VERSION
--Microsoft Azure SQL Data Warehouse - 10.0.15661.0 Jun 20 2022 23:32:43 Copyright (c) Microsoft Corporation
Note: OPENJSON still works fine
EDIT:
Screenshot from SSMS:
Screenshot from Synapse Workspace:
EDIT: I have updated the title and question to clarify that this is a DEDICATED SQL Pool.
I have tried with some sample values in my local environment, and it is working without errors.
select ##version version_name
--ex:1
declare #json nvarchar(max) = '{"time":"2015-04-29T07:12:20.9100000Z","callingimsi":"466920403025604","switch1":"China","switch2":"Germany"}'
select #json as json_value
where ISJSON(#json)=1
--ex:2
declare #json1 nvarchar(max) = 'abc'
select #json1 as json_value1
where ISJSON(#json1)=1
--ex:3
SELECT ISJSON('{"a":1}') as validate_json
We've hit this same issue.
ISJSON function works normally on Azure SQL databases, works normally on serverles SQL pool in Synapse, but fails in dedicated SQL pool in Synapse. Looks like MS updated the ISJSON function in Azure, but not all Azure SQL databases have the same version deployed.
Related
execute msdb.dbo.sp_send_dbmail
etc etc
#query = 'select * from Mysql...MemberRef4 as oi where oi.MemberId = 133363 '
The above is a query that I plugged into an existing working send mail method. MySql is a linked MySql database. I CAN run this query without any errors, correctly, by selecting the query code and F5. I am running this code and other MySql code joins with SqlServer and other linked servers - without any errors, including views/procs/etc.
However, the sp_send_dbmail method fails with :
Msg 22050, Level 16, State 1, Line 0
Failed to initialize sqlcmd library with error number -2147467259.
Note: this is the first time I'm trying to put MySql queries in sp_send_dbmail
Any help please. I really don't want stored procs that create temp tables/etc :(
I am using MVC3 and Entity Framework for calling a stored procedure in SQL Server 2008. The procedure has no parameters and in the profiler I get the proc execution as
exec sp_executesql N'sp_GetDashSessionboardRoomTimeSlot', N'#p0 nvarchar(4000)', #p0=NULL
This is how I call in the c# code.
SqlParameter sa = null;
var query = from dashboardData in TBSCIDBContext.Database.SqlQuery<SessionDashboardData>("sp_GetDashSessionboardRoomTimeSlot", sa)
select dashboardData;
This works fine. But I have changed my database to SQL Server 2005 and I need to use it
So when I call the same procedure using the same C# code the profiler returns the same exec statement but the sql gives error
Incorrect syntax near 'sp_GetDashSessionboardRoomTimeSlot'
pls help me in how to fix this problem as I need to use this stored procedure and in SQL Server 2005
changed it to
var query = from dashboardData in TBSCIDBContext.Database.SqlQuery("sp_GetDashSessionboardRoomTimeSlot")
select dashboardData;
it works
Change the ProviderManifestToken in SSDL (in your EDMX) to 2005. You probably have it set to 2008.
I am able to call a procedure on a linked server (MySQL) from Sql2k5. The procedure returns a single row, single column:
declare #Statement nvarchar(200)
set #Statement = 'call database.procedure(''some string'');'
exec (#Statement) at [linkedserver]
... results:
some string
What I need now is to set a variable to the value returned from the procedure
I found a somewhat related post here.
but when I try to insert the executed results:
insert into sometable exec (#Statement) at [linkedserver]
I get this error:
OLE DB provider "MSDASQL" for linked server "linkedserver" returned message "[MySQL][ODBC 5.1 Driver]Optional feature not supported".
Msg 7391, Level 16, State 2, Line 3
The operation could not be performed because OLE DB provider "MSDASQL" for linked server "linkedserver" was unable to begin a distributed transaction.
Is there a way to get around this, or a much better way to get at those results?
Thanks,
Linked servers are a real pain, especially when metadata gets screwed up. An “insert” is a distributed transaction no matter if you use BEGIN/COMMIT TRAN though (inserts cause log usage). Have you tried OPENQUERY yet? Or try these ideas:
http://www.sqlservercentral.com/Forums/Topic714869-338-1.aspx#bm716699
Note the provider and the linked server options in the following link:
http://www.infi.nl/blog/view/id/4/How_To_MySQL_as_a_linked_server_in_MS_SQL_Server
ERROR MSG: The requested operation could not be performed because OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" does not support the required transaction interface.
I am stucked finding solutions for this error (see ERROR MSG).
Here is part of my code:
.....
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;
Database=C:\Folder\file_output.xls',
'SELECT * FROM [Sheet1$]')
SELECT FROM FIELD1, FIELD2, FIELD3 dbo.MY_TABLE
WHERE TRANS_ID = 1
ORDER BY CTRL_NO ASC
.....
The above code is contained inside an SP... This is the last SP that is run in a series of SP calls.
Here is the chain/flow of execution: SP1->SP2->SP3->SP4 (assuming SP4 contains the above code)
But an error occurs as what the ERROR MSG suggests during the entire execution flow.
Here are the 2 scenarios that I've tried to test/trace the error.
- Run the the chain of SPs ----> result: error occurs
- Comment/Remove SP4, then run SP1->SP2->SP3 only. Then separately execute SP4. ----> result: okay
PLS. NOTE:I need to execute the SPs in flow.
There is no web/any front-end except SP1 is executed through SQL runner
I now wonder if this is a bug in MS SQL Server 2008 or I'm missing something.
If my question is still vague, kindly ask me for clarification. Thanks.
Try to check "Non transacted updates" option in "Server objects - Linked servers - Providers - Microsoft.Jet.OLEDB.4.0" properties. Maybe you will need to restart your sql server.
I'm having issues when trying to call a MySQL (5.0.77) stored procedure with parameters, via a linked server (SQL Server 2005) using the OPENQUERY syntax.
The MySQL stored procedure returns a result set, and when I use the 'EXEC ... AT ...' syntax the call works fine, e.g...
EXEC('CALL my_stored_proc(''2009-10-07'',''2009-10-07'');') AT MySQLSERVER;
The limitation of using 'EXEC ... AT ...' means I can't insert the result set into a temporary table in SQL Server, which is ultimately what I want to do. Which led me to trying the OPENQUERY syntax...
SELECT * FROM OPENQUERY(MySQLSERVER,'CALL my_stored_proc(''2009-10-07'',''2009-10-07'');')
...But this fails, and returns...
Msg 7357, Level 16, State 2, Line 1
Cannot process the object "CALL my_stored_proc(''2009-10-07'',''2009-10-07'');". The OLE DB provider "MSDASQL" for linked server "MySQLSERVER" indicates that either the object has no columns or the current user does not have permissions on that object.
Which is strange, given that the 'EXEC ... AT ...' call didn't complain about permissions. The following calls all work fine...
EXEC('SHOW TABLES;') AT MySQLSERVER;
SELECT * FROM OPENQUERY(MySQLSERVER,'SHOW TABLES;');
CREATE TABLE #tmpTest (
[table] varchar(255) null
);
INSERT INTO #tmpTest ([table])
SELECT * FROM OPENQUERY(MySQLSERVER,'SHOW TABLES;');
SELECT * FROM #tmpTest;
DROP TABLE #tmpTest;
So my question is, how can I make a call to a MySQL stored procedure, via a linked server, and store the result set in a temporary table in SQL Server? Either by using the 'EXEC ... AT ...' syntax, or by solving the object/permissions error when using the OPENQUERY syntax.
Any help would be greatly appreciated!
You need to enable "Ad Hoc Distributed Queries" on the SQL Server. This is not enabled by default, for security reasons. Most of the time, the "do not have permission" errors are related to this one.
Execute this on the SQL Server, and then try again your code:
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
I hope it helps.
I tried the fix to configure "Ad Hoc Distributed Queries" but was still getting this same error:
"The OLE DB provider "MSDASQL" for linked server "MyMySQL" indicates
that either the object has no columns or the current user does not
have permissions on that object."
I am attempting a simple remote SELECT query against a linked MySQL database.
In my case, the query I was attempting looked like this. Pay attention to the number of lines used:
SELECT * FROM OPENQUERY
([MyMySQL],
'
SELECT
ID as ISSUE_ID, etc..
The fix was to remove the newline after the opening single-quote. Simple, huh? But not obvious.
The working code shown below:
SELECT * FROM OPENQUERY
([MyMySQL],
'SELECT
ID as ISSUE_ID, etc..
Hope it helps!
Rob
I realize this a pretty old post, but my problem was similar to Rob's in that the SQL within the OPENQUERY doesn't take line breaks as whitespace the same way SQL server does.
i.e. Laying out my query as follows:
SELECT
*
FROM
OPENQUERY(LINKEDSERVER, '
SELECT
SomeField
FROM
SomeTable
')
I needed to have spaces as if it were written on one line (using _ as a visible space for demonstration):
SELECT
*
FROM
OPENQUERY(LINKEDSERVER, '
SELECT_
SomeField_
FROM_
SomeTable
')