Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Posts
    4

    Question Unanswered: Using a SP in a select statement

    I have forgotten how to use a stored procedure in a select statement.

    I have created a SP:
    ----------------------------------------------------------------
    CREATE PROCEDURE [dbo].[vsp_GetLOVValue]
    AS
    RETURN '10000'
    GO
    ----------------------------------------------------------------
    I would like to use this SP in a select statement I am running in query analyzer.
    I tried this but it did not work.

    Select vsp_GetLOVValue from users <User being a table of user names>

    I can run exec vsp_GetLOVValue and it says it is working but I would like to use it in a select statement.

    Thanks,

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You need to write this as a UDF (User-defined function).

    create function dbo.GetLOVValue()
    returns varchar(6)
    as
    return '1000'
    end


    You use it like this:

    Select dbo.GetLOVValue() from users

    Note that you MUST include the function owner when calling a scalar UDF.

    Welcome to SQL Server 2000
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •