SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 CTE-parameter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

inbs
Aged Yak Warrior

834 Posts

Posted - 02/22/2013 :  08:03:58  Show Profile  Reply with Quote
hi
i have this query,and i want use paramate in cte,
i get the error below, what's the problem?


DECLARE @StockDate AS DATETIME

SET @StockDate = (SELECT LastStockDate FROM FullDateStock)

WITH CTE_getData AS
(
SELECT MAX(CurrDate) AS CurrDate,Product
FROM 
WHERE CurrDate<@StockDate
GROUP BY Product
)
SELECT  * FROM CTE_getData


Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

webfred
Flowing Fount of Yak Knowledge

Germany
8764 Posts

Posted - 02/22/2013 :  08:06:36  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by inbs

hi
i have this query,and i want use paramate in cte,
i get the error below, what's the problem?


DECLARE @StockDate AS DATETIME

SET @StockDate = (SELECT LastStockDate FROM FullDateStock)

;WITH CTE_getData AS
(
SELECT MAX(CurrDate) AS CurrDate,Product
FROM fromWhat???
WHERE CurrDate<@StockDate
GROUP BY Product
)
SELECT  * FROM CTE_getData


Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.




Too old to Rock'n'Roll too young to die.

Edited by - webfred on 02/22/2013 08:08:03
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.33 seconds. Powered By: Snitz Forums 2000