Amit Bisht
Amit Bisht

Reputation: 5136

how to set return type of a stored procedure

I am using this stored procedure

ALTER PROCEDURE [dbo].[MyProcedure]
    @pSelect nvarchar(max)
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @SQL nvarchar(max)

    SET @SQL = 'Select'  + @pSelect + ' from '
tabel1;
    Exec sp_executesql @SQL
END

it is returning me a integer type value i want it to return a value of type tabel1

is it possible

Upvotes: 0

Views: 3101

Answers (2)

Raging Bull
Raging Bull

Reputation: 18737

Try this:

ALTER PROCEDURE [dbo].[MyProcedure]
    (@pSelect nvarchar(max))
AS
BEGIN
    SET NOCOUNT ON;

    select @pSelect from Table1

END

Call the stored procedure as:

exec MyProcedure 'field_name'

I hope this is what you are trying to do.

Upvotes: 2

Ashutosh Arya
Ashutosh Arya

Reputation: 1168

Sorry , SP DON'T RETURNS VALUES UNLESS YOU ARE USING OUT PARAMETERS

REGARDS

ASHUTOSH ARYA

Upvotes: 1

Related Questions