August 16, 2005 at 4:11 am
In the function given below, i want to replace SIS with function variable @DBName.How can i do this??
CREATE Function salesVolumeCompare(@ID int,@Year int,@DBName varchar(40))
RETURNS bigint
AS
BEGIN
DECLARE @vol BIGINT,@sqlSTR varchar(40)
SET @sqlSTR=SIS.dbo.salesVolume(@ID, @Year)
--SET @vol=CAST((SELECT SF.dbo.salesVolume(@ID, @Year) FROM tblSalesItem WHERE tblSalesItem.ID = @ID) AS bigint)
SET @vol=CAST((SELECT @sqlSTR FROM tblSalesItem WHERE tblSalesItem.ID = @ID) AS bigint)
if @vol is null
SET @vol = 0
RETURN (@vol)
END
August 16, 2005 at 6:24 am
You can't do that. You need to use sp_executesql to fetch output values from dynamic sql, and you need to use a stored proc to do that. Sorry I don't have any exemples of that.
August 16, 2005 at 6:31 am
Thanks!!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply