skmasq
skmasq

Reputation: 4521

SQL Server stored procedure returns value in select statement

I have no experience with stored procedures whatsoever so I want to ask if something like this is possible.

Stored procedure returns

replace(rtrim(replace(
       replace(rtrim(replace(cast(@returningValue as varchar(40)), '0', ' ')), ' ', '0')
       , '.', ' ')), ' ', '.')

and this is called like this

SELECT storedProcedure(aDecimalValue)
FROM   Table

Upvotes: 1

Views: 70

Answers (1)

SoulTrain
SoulTrain

Reputation: 1904

You could do this with a SCALAR VALUED function..

CREATE FUNCTION dbo.TEST_FUNCTION_NAME1 (@returningValue  VARCHAR(40)) 
        RETURNS VARCHAR(40) AS 
    BEGIN 
    return replace(rtrim(replace(
       replace(rtrim(replace(cast(@returningValue as varchar(40)), '0', ' ')), ' ', '0')
       , '.', ' ')), ' ', '.')

    END

Then you could do some thing like

SELECT dbo.TEST_FUNCTION_NAME1(string)

Upvotes: 3

Related Questions