Friday, March 23, 2012

Incorrect syntax near comparison on parameter value

Error: Incorrect syntax near '@.today'.

DECLARE @.today CHAR(8)

SET @.today = CONVERT(CHAR(8), GETDATE(), 112)

SELECT c.name,

c.cust,

m.num,

ph.Entered

FROM Master m (NOLOCK)

INNER JOIN dbo.hisy ph ON ph.number = m.num

INNER JOIN dbo.Cust c ON c.Cust = m.Cust

WHERE m.customer IN (0000162, 0000164)

AND ph.Entered IS NOT NULL

AND CONVERT(CHAR(8), ph.Entered, 112) = @.today <-Error is here

It passes syntax checking for me. Is this the entire batch?

If I add a BEGIN before the statement, I get the syntax error two. Sometimes SQL Server error messages are really misleading, though it is technically correct.

|||thanks I was missign the END, that was it.

No comments:

Post a Comment