I am running the following query using Query Analyzer against an MSDE version. The query seems like a textbook use of 'LIKE', so the error makes to sense to me. Thanks for any help.
SELECT _FAX
FROM _IRISH_BNB_DETAILS
WHERE _FAX LIKE "[A-Z]%"
Error:
Server: Msg 207, Level 16, State 3, Line 1
Invalid column name '[A-Z]%'.
Try executing:
SET QUOTED_IDENTIFIER OFF
|||Dave
In SQL, use the single quote character to delimit strings, so:
LIKE '[A-Z]%'
instead of
LIKE "[A-Z]%"
Double quotes are used to allow for quoted identifiers, so it is thinking that "[A-Z]%" is a column name
|||Thank you!
I was following an example in "SQL Server 2000 Administrator Companion" on page 309 that uses double quotes.
|||Sorry, my answer is too short. Try this:
SET QUOTED_IDENTIFIER OFF
SELECT _FAX
FROM _IRISH_BNB_DETAILS
WHERE _FAX LIKE "[A-Z]%"
SET QUOTED_IDENTIFIER ON
and then try this:
SELECT _FAX
FROM _IRISH_BNB_DETAILS
WHERE _FAX LIKE '[A-Z]%'
You are really better changing your literal, that is "[A-Z]%" into a single quote delimited literal for the sake of ANSI compliance; however, an alternative is to set QUOTED_IDENTIFIER on so that the original code can work as is.
|||Yeah, Louis answered before I could correct myself. Sorry about that.|||Yeah, and you answered while I was answering :)|||Dave
Hey, it was a typing war! You won!
:-)
No comments:
Post a Comment