Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
CREATE FUNCTION GetClientName
(
    @JobId bigint
)
RETURNS VARCHAR(MAX)
AS
BEGIN
    DECLARE @ClientName AS VARCHAR(MAX)
    select @ClientName = c1.clientname FROM tbl_client c1
    INNER JOIN tbl_mechanicalbrief m ON m.clientid = c1.clientid
    WHERE mechanicalid = @JobId
    Union
    select @ClientName = c2.clientname FROM tbl_iteration i
    INNER JOIN tbl_client c2 ON i.clientid = c2.clientid
    WHERE iterationid = @JobId
    Union
    select @ClientName = c3.clientname FROM tbl_release r
    INNER JOIN tbl_client c3 ON r.clientid = c3.clientid
    WHERE releasingid = @JobId
    RETURN @ClientName
END


When I execute above SQL Statement it gives an error:
Select statements included within a function cannot return data to a client.


How can solve this problem??
Posted

1 solution

Here you go, this explains why it is so and how it can be resolved: SQL Server Error Messages - Msg 444[^]
 
Share this answer
 
Comments
gopal2007 13-Oct-10 5:34am    
Ya i have gone through it.
but m calling this function in SP.

how u can call SP in other SP..!!
Sandeep Mewara 13-Oct-10 5:48am    
Here you go:
http://www.aspfree.com/c/a/ASP.NET-Code/Call-Stored-procedure-from-within-another-stored-procedure-return-values/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900