Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Use Parameter as Column Name Error

Author  Topic 

daniel50096230
Yak Posting Veteran

99 Posts

Posted - 2012-03-01 : 23:21:04
Hi,

I has the following codes:

DECLARE @date date
SET @date = '2011-08-01'

SELECT

PD.Product_ID
,SC.Branch_ID
,PD.Company_ID
,INVENTORY.cfn_GetStockConsumptionByProductWithException(PD.Product_ID,'BW',@date,DATEADD(day,6,@date),'MY03') AS DATEADD(day,6,@date)


I get error when I try to return the function AS DATEADD(day,6,@date). Is it I can't declare like this?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-01 : 23:23:27
you cant unless you use Dynamic SQL. Didnt understand why you need to create alias dynamically? cant this be generated at front end?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -