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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

inbs
Aged Yak Warrior

860 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
8781 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  
 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.04 seconds. Powered By: Snitz Forums 2000