Reputation: 37
INSERT INTO Article (CatID, Title, Content)
VALUES ('100', 'New color, new choice', '<span style="font-family:'Times New Roman'">etc...etc</span>')
I try to insert data into a table in SQL Server with this command, but I get an error:
Incorrect syntax near 'Times'
What is wrong here, and how can I fix it?
Upvotes: 0
Views: 729
Reputation: 13237
Around the Times New Roman in the Content
value, you need to add '
to escape the single quotes:
INSERT INTO Article (
CatID
,Title
,Content
)
VALUES (
'100'
,'New color, new choice'
,'<span style="font-family:''Times New Roman''">etc...etc</span>'
)
Upvotes: 1
Reputation: 118947
You have unescaped single quotes in the third column. Use a double single quote (''
) to escape that:
INSERT INTO Article
(CatID, Title, Content)
VALUES
('100', 'New color, new choice', '<span style="font-family:''Times New Roman''">etc...etc</span>')
-- ^^ This and this ^^
Upvotes: 1
Reputation: 2185
You need to escape single quote, using two single quotes:
Insert into Article(CatID, Title, Content) values ('100','New color, new
choice','<span style="font-family:''Times New Roman''">etc...etc</span>')
Right after and before Times New Roman there are two '
characters instead of one, otherwise the interpreter will think the string ends with ...family:
Upvotes: 1