Home All Groups Group Topic Archive Search About

sql server 2005 quoted_identifier don't work

Author
11 Nov 2005 5:21 PM
Roger
Hi all

I am using sql server 2005 and I try this:

set quoted_identifier on
go
select "roger"

and I receive a error:
Msg 207, Level 16, State 1, Line 1
Invalid column name 'roger'.

Why ???

Author
11 Nov 2005 5:35 PM
Tony Rogerson
Its looking for a column named "roger".

set quoted_identifier on

go

create table test (

"roger" int not null

)

go


select "roger"

from test


--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials


Show quote
"Roger" <roger@rnospam.com> wrote in message
news:OlqzUQu5FHA.1184@TK2MSFTNGP12.phx.gbl...
> Hi all
>
> I am using sql server 2005 and I try this:
>
> set quoted_identifier on
> go
> select "roger"
>
> and I receive a error:
> Msg 207, Level 16, State 1, Line 1
> Invalid column name 'roger'.
>
> Why ???
>
>
>
>
>
>
Author
11 Nov 2005 11:32 PM
Hugo Kornelis
On Fri, 11 Nov 2005 15:21:55 -0200, Roger wrote:

>Hi all
>
>I am using sql server 2005 and I try this:
>
>set quoted_identifier on
>go
>select "roger"
>
>and I receive a error:
>Msg 207, Level 16, State 1, Line 1
>Invalid column name 'roger'.
>
>Why ???

Hi Roger,

This is working as expected. The quoted identifier option is used to
force ANSI-conform behaviour. And ANSI states:

- String constants are enclosed in 'single quotes'
- Column names, table names and other identifiers may be enclosed in
"double quotes" - and this must be done if the identifier is a reserved
word or contains spaces or other characters that are not allowed in an
identifier.
- (And though ANSI doesn't specify it, SQL Server will also accept
identifiers enclosed in [square brackets] to preserve compatibility).

With quoted identifier off (which I would advise against, BTW), you
would mimic the old pre-7.0 behaviour:
- String constants enclosed in either 'single' or "double" quotes
- Identifiers enclosed in [square brackets].


If you just want to return the text "roger", use

SELECT 'roger'

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

AddThis Social Bookmark Button