You need to use sp_executesql to make use of output variables:set nocount onuse pubsgocreate function dbo.fn_junk(@v varchar(10)) returns int asbegin return 1endgo--EDIT:--this was just to test my function--select dbo.fn_junk('tg')declare @tmp int ,@cmd nvarchar(500) ,@params nvarchar(500)select @cmd = 'select @tmp = dbo.fn_junk(''tg'')' ,@params = '@tmp int output'exec sp_executesql @cmd, @params, @tmp=@tmp outputselect @tmp [@tmp]godrop function dbo.fn_junk
Be One with the OptimizerTG