|
Posted by Erland Sommarskog on 12/18/06 22:17
findu_2005@yahoo.com (findu_2005@yahoo.com) writes:
> When I run the following command on sql server:
>
> exec ('print "OK"')
> go
>
> This message appears:
>
> Server: Msg 128, Level 15, State 1, Line 1
> The name 'OK' is not permitted in this context. Only constants,
> expressions, or variables allowed here. Column names are not permitted.
>
> Why? Thanks.
Because when the setting QUOTED_IDENTIFIER is in effect, "" delmits
identifier. This permits you to use table names like Order Details, for
instance:
SELECT ... FROM "Order Details"
In the SQL Server world, we tend to use [] for this function, but "" is
what ANSI mandates.
QUOTED_IDENTIFIER is on by default in most contexts, but not when you
run from SQLCMD, OSQL or Enterprise Manager in SQL 2000. Or for that
matter all DB-Library applications.
When the setting is off, SQL Server reverts to the original behaviour
from 4.x days when you couls use both '' and "" to delimit strings.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|