Stored procedure execution in Entity Framework in SQL Server 2005 - sql-server-2008

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.

Related

ISJSON in Azure Synapse Dedicated SQL pool

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.

Translate := from MySQL to SQL Server 2014

I had several troubles when translating a stored procedure from MySQL to SQL Server 2014 with the assign operator :=.
What solution is suggested?
Check the following link: http://dev.mysql.com/doc/refman/5.7/en/assignment-operators.html#operator_assign-value
You can use = in your T-SQL script instead.

MySQL Stored Procedure Call from SSRS through ODBC

I'm trying to call a stored procedure that takes one parameter on Mysql from ssrs. Connecting through ODBC. I use following syntax for calling using query designer:
`CALL test.ClientSelectExtract(?)`
And I'm getting following error.
`SQLBindParameter not used for all parameters`
I found the solution. Read from an article that MySql ODBC don't support named parameters.
So I called the stored proc like this
CALL test.ClientSelectExtract(?)
Added a parameter named parameter1 in the Parameters Folders then set the type and value, then explicitly created a parameter named parameter1 to reference the ? on the dataset also, then all worked fine.
Note: If I had more ? placeholders the next param would be parameter2, same steps and so on.
You should create linked server in SSMS from MYSQL then only we will call the stored procedure. syntax to call stored procedure:
EXEC ('CALL GASP_sales_aps(?, ?)', #dt_start, #dt_end)AT MySQL(Linked Server Name)
GASP_sales_aps ---->procedure Name
(#dt_start,#dt_end)------> are parameters .

MySql MVC3 EF Code First with Stored Procedure

I have a stored procedure created in MySql to return a resultset as
CREATE PROCEDURE GetCount()
BEGIN
SELECT count(*)
FROM mytable;
END$$
I am trying to call this from my MVC3 application using EF CF as:
int count = myContext.Database.SqlQuery<int>("GetCount").First();
It is falling over the call to test in my application with an error ;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GetCount' at line 1
Is this not supported using MySql? Obviously the above works perfectly fine with MS Sql Server 2008. So just wondering if this is a problem with the MySql side.
Thanks
Try
int count = myContext.Database.SqlQuery<int>("CALL GetCount()").First();

Getting SQL stored procedure results into data.frame format using RODBC

I am using the RODBC package to query for results in my SQL server. I have a certain stored procedure written that, when executed in my SQL Server Mgmt. studio (for example), returns a table. However, when I run the query through R, it returns character(0)
# Execute command...
sqlQuery(production,"exec port.tdp_RISK2_ModelRunCompare #ModelRunId1 = 399")
Weird thing is... when I do something like...
sqlQuery(production,"exec sp_who")
I get a table of results...
Help?
I had the same problem.
You can try using:
set nocount on
in the MS SQL Server stored procedure so it will return just a dataset.
Regards,
Try this:
sqlQuery(production,"exec port.tdp_RISK2_ModelRunCompare #ModelRunId1 = 399", errors=FALSE)
Also try writing to a new data frame. I kept getting character(0) when I tried to overwrite an existing data frame with the sqlQuery function.