I am in the process of importing an Oracle database into SQL Server.
Once of the tables has a field called "EXEC".
SQL Server seems to reject any queries that include that particular
field because EXEC is a keyword. For eg.
SELECT ID, EXEC from USERS
results in a syntax error near keyword EXEC.
I can't change the fieldname becuase it will require reworking of a
whole bunch of scripts.
What can I do to adjust the query?
Bijoy
You can use square brackets as delimiters:
select [EXEC] from ...
See "Delimited Identifiers" and "Using Identifiers" in Books Online for
more information.
Simon
|||Try
SELECT [ID], [EXEC] FROM Users
Regards
Steen
b_naick@.yahoo.ca wrote:
> I am in the process of importing an Oracle database into SQL Server.
> Once of the tables has a field called "EXEC".
> SQL Server seems to reject any queries that include that particular
> field because EXEC is a keyword. For eg.
> SELECT ID, EXEC from USERS
> results in a syntax error near keyword EXEC.
> I can't change the fieldname becuase it will require reworking of a
> whole bunch of scripts.
> What can I do to adjust the query?
> Bijoy
|||(b_naick@.yahoo.ca) writes:
> I am in the process of importing an Oracle database into SQL Server.
> Once of the tables has a field called "EXEC".
> SQL Server seems to reject any queries that include that particular
> field because EXEC is a keyword. For eg.
> SELECT ID, EXEC from USERS
> results in a syntax error near keyword EXEC.
> I can't change the fieldname becuase it will require reworking of a
> whole bunch of scripts.
> What can I do to adjust the query?
Rather than using [] as suggested in other posts, "" may be better.
SELECT ID, "EXEC" FROM USERS
[] is usually preferred on SQL Server. However, that is proprietary syntax,
whereas quoting with "" is ANSI-compliant, and may thus work on Oracle as
well.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
sql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment