Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help- function not returning my value- why

Status
Not open for further replies.

rtdvoip

Programmer
Aug 29, 2003
27
US
Can someone shed some light on this and tell me
why when I do an 'exec rtd_voip_ret' in a query window
that I do not get a return value? When I run it ouside the function it works fine.

Create Function rtd_voip_ret ()
Returns varchar(20)
as
begin
Declare @next_id varchar(20)
set @next_id = (select max(cast(substring(voip_id,4,len(voip_id))as int)) from customer_record) +1
set @next_id = 'VA-'+@next_id
return @next_id
end

thanks in advance,
rtdvoip
 
Because it's a function not a stored procedure.

By understanding the centents of your user defined function.You dont really need a function but stored procedure.

Create Procedure rtd_voip_ret
as
Declare @next_id varchar(20)
set @next_id = (select max(cast(substring(voip_id,4,len(voip_id))as int)) from customer_record) +1
set @next_id = 'VA-'+@next_id
select @next_id

--usage
--exec rtd_voip_ret
 
try

select dbo.rtd_voip_ret()


A scalar valued function returns a value it doesn't display it.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top