Board index » delphi » Problems while executing queries in SQL Server 2000

Problems while executing queries in SQL Server 2000

Hi,

    Problem while running the following sql query in MS SQL Server 2000, but
it works fine in SQL Server 7.

    select * from master where surname = "RAJEEV"

    It shows the error  msg :     Invalid column name '001'.

    If I use single quotes instead of double quotes (for eg: select * from
master where staffno = 'RAJEEV') it works fine in SQL Server 2000. Is there
any settings in the SQL Server 2000 so that I can use double quotes instead
of single quotes in the above sql statement. I don't want to make changes in
the SQL statement because I had used double quotes in lots of places in the
code and the code is working fine for SQL Server 7. Now I want to shift my
databases to SQL Server 2000.

Can anyone help me ??

Thanks
Rajeev R

 

Re:Problems while executing queries in SQL Server 2000


Why not to use Parameters ?

select * from master where surname = :surname

in that way doesn't matter what kind of quotes the server uses

Re:Problems while executing queries in SQL Server 2000


Quote
"Rajeev Ramanujan" <rajeevramanu...@hotmail.com> wrote in message

news:3e82d0ae@newsgroups.borland.com...

Quote

>     select * from master where surname = "RAJEEV"

>     It shows the error  msg :     Invalid column name '001'.

>     If I use single quotes instead of double quotes (for eg: select * from
> master where staffno = 'RAJEEV') it works fine in SQL Server 2000. Is
there
> any settings in the SQL Server 2000 so that I can use double quotes
instead
> of single quotes in the above sql statement. I don't want to make changes
in
> the SQL statement because I had used double quotes in lots of places in
the
> code and the code is working fine for SQL Server 7. Now I want to shift my
> databases to SQL Server 2000.

I strongly advise you to bite the bullet and make the changes to your
queries. Single quotes for field values is the standard for SQL and all you
are seeing is MS SQL deciding to enforce that better (Interbase also began
enforcing this with version 6). Double quotes (again by standard) indicate a
meta object name (field or table, etc) and so the server is trying to find a
field named "RAJEEV".

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
"Democracy, without that guarantee of liberty, is merely a method of
selecting tyrants." - Alan Nitikman

Other Threads