-
User Functions as params to Stored Procs
Can I use the result of a scalar function as the parameter for a stored procedure? ie
exec [dbo].[usp_insert_into_table]
@integer = [dbo].[uf_getAnIDfromName]('PLAYER')
where the @integer parameter expects an integer and the user function uf_getAnIDFromName returns an integer related to the 'PLAYER' name.
-
I dont think so. u need a variable.
create proc test @var1 int as
print @var1
create function udf1 (@x varchar(10))
returns int
as
begin
declare @y int
if @x = 'Player'
begin
set @y =1
end
else
begin
set @y =5
end
return @y
end
--select dbo.udf1('Playerw')
declare @xx int
set @xx = dbo.udf1('Playerw')
exec test @var1 = @xx
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|