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
 General SQL Server Forums
 New to SQL Server Programming
 Syntax error in this statement?????

Author  Topic 

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2011-10-25 : 10:59:14
I just executed this query successfully yesterday afternoon. Changed nothing, came in this morning to run it again, and it's showing syntax errors where there were none previously. Any ideas? The syntax errors are on the first comma after the 'GCSO011100000000ENF' value in the select and on the closed paren at the end of the statement.:

INSERT INTO CIVIL.dbo.RECEIPTS
(
RECEIPTNO,
RECEIVEDATE,
CATEGORY,
TYPEWRIT,
PLAINTIFF,
DEFENDANT,
COURTNAME,
CASENO,
COURTDATE,
DEPOSITAMOUNT,
PAYMENTTYPE,
CHECKNO,
REFUNDDATE,
REFUND,
REFUNDCHECKNO,
ATTORNEYID,
COMMENTS,
UNIQUEKEY,
ProcessTypeFKey
)
Select
(
'GCSO1110000000000ENF',
'1/2/2007',
'10',
'ORDER OF CONTEMPT AND WARRANT FOR COMMITMENT',
'COMMERCE CREDIT UNION',
'Jane Doe,
'COUNTY-LEON',
CASE
WHEN LEN('2004 SC 2135') > 20 THEN 'See Comments'
ELSE '2004 SC 2135'
END,
'',
'20',
'2',
'35801',
NULL,
0,
'35801',
'382',
CASE
WHEN LEN('2004 SC 2135') > 20 THEN '2004 SC 2135'
ELSE ''
END,
SCADMIN.dbo.fnsc_GetUniqueID(NEWID()),
'3H4Lx74A10kfKsjyvc2Ymf'
);

Thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2011-10-25 : 11:39:36
two things:
1 - You're missing a close-quote after: 'Jane Doe,
2 - Either remove the parentheses around the SELECT statement
OR Change the word "SELECT" to "VALUES"

Be One with the Optimizer
TG
Go to Top of Page

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-10-25 : 11:40:58
You've a missing ' after Jane Doe on your SELECT statement.

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk A Bury FC supporters website and forum
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2011-10-25 : 12:36:38
Aargh. Thank you.
Why, with all that SQL can now do, do we still have to see "Syntax error near...."?? It certainly seems to me like the parsing could have seen that a string was started where the first "'" existed on that line, and have pointed that out, suggesting, perhaps, that i was simply missing the second "'".
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2011-10-25 : 13:10:05
how is it supposed to assume where the end of the string is? not everyone uses a <CR> as a line break.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -