开发者

SQL Server Query - Insert problem

I'm having a problem with an insert query in SQL Server. The full text of the query is

insert into franchise (fran_id, name, address1, address2, city, state, zip, email, phone, text) 
values(0, "DevFranchise1", "101 Main St.", "-", "Brighton", "Mi", "48116", "dev1@franchisezippy.com", 8105551234, "asdflkjsadf");

Now "state" and "text" both highligh blue. It gives me a list of errors like the following:

Msg 207, Level 16, State 1, Line 1
Invalid column name 'DevFranchise1'
Msg 207, Level 16, State 1, Line 2
Invalid column name '101 Main St.'

What开发者_StackOverflow社区 does this mean / how can I fix it?


String literals should be in single quotes ('), not double quotes (").

Additionally, right angled brackets ([]) will allow you to use keywords (such as state and text) as column names. This is not always necessary, but provides a way out in ambiguous situations.

insert into franchise
    (fran_id, name, address1, address2, city, [state], zip, email, phone, [text])
values
    (0, 'DevFranchise1', '101 Main St.', '-', 'Brighton', 'Mi', '48116',
    'dev1@franchisezippy.com', 8105551234, 'asdflkjsadf');


Try to use single quotes (') instead of double (").

Otherwise, your values seem to be considered as column names.


use Single quotes and it will probably work.


You have to use single quotes in SQL.


Use the single quote character not the double quote character in SQL


set quoted_identifier off

before the insert.

But better is use single quotes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜