Reputation: 1055
I have a selection of sql code that I keep getting an 'Incorrect syntax' error on.
I cannot see what is causing the issue.
Can anyone point out the obvious to me? I maybe have been staring at the code for too long to see it now!!
My code is :-
DECLARE @CostCatID AS Int
SELECT * FROM vwREP_GP_ContractProjectPurchaseRpt
WHERE PACOSTCATID IN (@CostCatID)
AND (DOC_DATE >= @DateFrom)
AND (DOC_DATE <= @DateTo)
order by 1
and the full error message I get is:-
Incorrect syntax near ';'
I know it is going to be obvious to most people but for the life of me in my tired state I cannot get this to work.
Thanks in advance.
(all work is being done in sql Server Management Studio 2005)
Upvotes: 1
Views: 463
Reputation: 13285
For once, the SQL error message is quite helpful:
Incorrect syntax near ';'
and you have the string >=
unquoted in you code.
I think you meant to use >=
and <=
instead.
Upvotes: 0
Reputation: 57593
You're using >
and <
: did you copy from a web page?
DECLARE @CostCatID AS Int
SELECT * FROM vwREP_GP_ContractProjectPurchaseRpt
WHERE PACOSTCATID IN (@CostCatID)
AND (DOC_DATE >= @DateFrom)
AND (DOC_DATE <= @DateTo)
order by 1
Upvotes: 0
Reputation: 247880
Not sure why you are using >
and <
, you need to use >
and <
DECLARE @CostCatID AS Int
SELECT * FROM vwREP_GP_ContractProjectPurchaseRpt
WHERE PACOSTCATID IN (@CostCatID)
AND (DOC_DATE >= @DateFrom)
AND (DOC_DATE <= @DateTo)
order by 1
Upvotes: 0
Reputation: 56459
>
and <
? Why are you encoding >
and <
? There's your problem. Try:
DECLARE @CostCatID AS Int
SELECT * FROM vwREP_GP_ContractProjectPurchaseRpt
WHERE PACOSTCATID IN (@CostCatID)
AND (DOC_DATE >= @DateFrom)
AND (DOC_DATE <= @DateTo)
ORDER BY 1
Upvotes: 4