Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 whats wrong with this function ?

Author  Topic 

mary_itohan
Posting Yak Master

191 Posts

Posted - 2008-09-14 : 08:57:21
create Function [dbo].[User_billing](@user varchar(30))

Returns varchar(30)
as

Begin
declare @priceplan varchar(20), @DefaultCountry int,@return varchar(30)
Return
(

select @DefaultCountry = DefaultCountry,@priceplan = priceplan
from history where username = @user

set @return = @DefaultCountry+','+@priceplan

return @return
)
End


I get this error

Msg 156, Level 15, State 1, Procedure User_billing, Line 14
Incorrect syntax near the keyword 'set'.
Msg 102, Level 15, State 1, Procedure User_billing, Line 17
Incorrect syntax near ')'.


_____________________


Yes O !

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-14 : 09:13:24
[code]CREATE FUNCTION dbo.fnUserBilling
(
@User VARCHAR(30)
)
RETURNS VARCHAR(30)
AS
BEGIN
RETURN (
SELECT CAST(DefaultCountry AS VARCHAR(11)) + ',' + PricePlan
FROM History
WHERE UserName = @User
)
END[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

mary_itohan
Posting Yak Master

191 Posts

Posted - 2008-09-14 : 09:37:14
Thank you Peso

_____________________


Yes O !
Go to Top of Page
   

- Advertisement -