Long term lurker, first poster here :)
I decided to ask here, since I'm tired of searching on Google, and so on. I am experiencing this error when importing a stored procedure from my SQL 2005 database to my site (FW 4.0, C #). LINQ Project:
"The return types for the following stored procedures cannot be detected."
I have two requests. I would like to note that I do not use temporary tables . These queries were edited only in variable names and, for example, for security measures. In any case, it works here:
ALTER PROCEDURE [dbo].[spMyWorkingProc] @OS numeric AS BEGIN SET NOCOUNT ON; DECLARE @sql varchar(5000) set @sql = ' SELECT * FROM MYDB.dbo.MYVIEW WHERE OS = ' + CONVERT(varchar, @OS) EXEC(' SET NOCOUNT ON SELECT * FROM OPENROWSET(''SQLOLEDB'', ''MYDB''; ''user''; ''password'', ''' + @sql + ''')') END
And here is one that is not :
ALTER PROCEDURE [dbo].[spNotWorking] @IDCLIENT int, @PPNO char(10) AS BEGIN SET NOCOUNT ON; DECLARE @sql varchar(5000) set @sql = ' SELECT * FROM MYDB.dbo.MYOTHERVIEW WHERE ID = ' + CONVERT(VARCHAR, @IDCLIENT) + ' AND PASSPORTNO = ' + @PPNO + ' ORDER BY AGE' EXEC(' SET NOCOUNT ON SELECT * FROM OPENROWSET(''SQLOLEDB'', ''MYDB''; ''user''; ''password'', ''' + @sql + ''')') END
Here is what I tried and found, as well as a few notes and questions:
Both users (LINQ and the remote server) are db_owner.
A non-working stored procedure works if I leave it with only one parameter (no matter which one). If I add a new one, this will not work.
If I create an empty SP with a simple selection * from any table and two or more parameters, it works (so it makes no sense).
Let's say the problem is in EXEC. If so, how does the first joint venture work? So there is no problem there. (which, it seems to me, is logic, I suppose?)
The problem is not the view, since it does not work if I use the view that I get in the working SP.
I need to do this using the provided requests. I canβt use linked servers or something like that, which is necessary for connecting to 6.5 databases, and it does not solve and does not explain why the first SP works and the second does not, using the same method.
I tried adding a parameter (taken from a non-working SP) to the working SP, and it works, so it should be something with the second SP, but I don't know what: /
Well, if I modify the second SP and delete the parameters in the @VAR style and hard code them into a single @sql variable, it works fine. So, I see that it should be something with the inclusion of variables in a dynamic query (or something else).
I literally pull my hair, so any ideas and suggestions are welcome!
Thanks in advance! - DARKGuy
DARKGuy
source share