Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The return types for the following stored procedures could not be detected

Tags:

linq-to-sql

While drag-drop a stored procedure in dbml file I get this error:

Unknown Return Type
The return types for the following stored procedures could not be detected. Set the return type for each stored procedure in the Properties window.

How can I resolve this error?

like image 471
sandeep Avatar asked Aug 12 '11 04:08

sandeep


People also ask

What is the return type of stored procedure?

Return Value in SQL Server Stored Procedure In default, when we execute a stored procedure in SQL Server, it returns an integer value and this value indicates the execution status of the stored procedure. The 0 value indicates, the procedure is completed successfully and the non-zero values indicate an error.

Can we use return in stored procedure?

You can use one or more RETURN statements in a stored procedure. The RETURN statement can be used anywhere after the declaration blocks within the SQL-procedure-body. To return multiple output values, parameters can be used instead. Parameter values must be set before the RETURN statement runs.

Can you return the null values using stored procedures?

No, the return type of a stored procedure is INT and it cannot be null.

Can a stored procedure return table?

The RETURN exits the stored procedure, and nothing that follows it will be executed, including the SELECT statement on the following line. Otherwise, if you want the data for the entire table, as your question shows, add a SELECT after the INSERT . But don't put RETURN in front of it!


1 Answers

This problem occurs whenever the designer cannot figure out the return type of the SP.
Same problem and solutions described here
How to get multiple result set of procedure using LINQ to SQL

Basically this is the solution from the link:

Avoid using #temp Table in your stored procedure, instead of you can use Table type variable like below (@TempTable)

Ex:

DECLARE @TempTable TABLE (   AttributeID INT,   Value NVARCHAR(200) )  INSERT INTO @TempTable Select * from Attribute  OR  --Execute SP and insert results into @TempTable INSERT INTO @TempTable Exec GetAttribute @Id 

You can do all operation which you was doing with #Temp table like Join, Insert, Select etc.

like image 156
Shebin Avatar answered Sep 27 '22 22:09

Shebin