Expand|Select|Wrap|Line Numbers
- SELECT TOP 100 PERCENT dbo.ReturnDoorPrice(dbo.[Quote Units].DoorStyle, dbo.[Quote Units].UnitNo) AS Door, dbo.UnitsCost.CODE,
- dbo.UnitsCost.DESCRIPTION
- FROM dbo.[Quote Units] INNER JOIN ... etc
Expand|Select|Wrap|Line Numbers
- Create Procedure [dbo].[ReturnDoorPrice](@Doorstyle int,@unit int)
- as
- begin
- declare @lvreturn as nvarchar(75);
- EXEC @lvreturn = dbo.ReturnDoorPriceString @Doorstyle,@Unit;
- print @lvreturn;
- exec sp_executesql @lvreturn;
- end
- Create Function [dbo].[ReturnDoorPriceString](@Door int,@unit int)
- returns nvarchar(75) as
- BEGIN
- declare @lvstring as nvarchar(75);
- set @lvstring = 'select top 1 ['+cast (@door as nvarchar(3))+'] FROM dbo.[Door Price] WHERE (ID = ' + cast (@unit as nvarchar(10)) +')'
- return @lvstring
- END
i then can get the valve ok by execute sample
EXEC dbo.ReturnDoorPrice 2,1780;
returns value 81.675
But used with select causes error
how can i?
- Use procedure within select statement
or
- fix function to return value, not string
any help appreciated