开发者

What is wrong with this insert query?

I am trying to run the following query in ms sql manager, but I keep getting syntax errors.

Msg 102, Level 15, State 1, Line 8
Incorrect syntax near ' '.

INSERT INTO dbo.Survey 
(
    Title, 
    Active, 
    StartDate, 
    EndDate
)
VALUES  
(
    'Title test', 
    '1', 
    null, 
    nu开发者_StackOverflow社区ll
);



// Table
SurveyId (primaryId)
Title  (varchar)
Active (bit)
StartDate (datetime)(nullable)
EndDate (datetime)(nullable)


Incorrect syntax near ' '

Double click on the error, it will bring you to the line in question

It looks like you have a blank character of some sort on line 8 (after Values)..paste it into something like NotePad++ and look for hidden characters

or change

VALUES  
(

to

VALUES(


Also, your table structure doesn't indicate if it is an indentity key. If it is not, the PK is required and thus must have a value to be inserted.

Second possiblity, the error is on a trigger on the table.


try inserting 1 or b'1' value to Active column


I've seen problems where a cut & paste between a unicode and non-unicode document looks fine, but acts strangely with different versions of SQL Server.

One thing I've done to fix this in the past is to do a Save As "with encoding" in Management Studio then select something like "Western European (Windows) - Codepage 1252.

To get the advanced save options, do a File, Save as, then click the arrow on the far right side of the save button and change to "Save with encoding".

Another solution would be to use something like PureText (free s/w) to cut & paste your code without having to go into Notepad as a middle step.

http://www.stevemiller.net/puretext/

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜