Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
$sql = "SELECT Kill FROM tbl_pvporderview";

Problem is that il lend up with : Incorrect syntax near the keyword 'Kill'.

Cuz kill is a TSQL command... any way to bypass it?

I cant change the column name cuz its used by the software a lot and i cant change the software that's using the database.

so it simply fails if i use sqlserv to select data from that column. '' or "" wont help.

The complete statement would be:

$sql = "SELECT serial,Kill FROM tbl_pvporderview WHERE Kill > (?) ORDER BY Kill DESC ";
share|improve this question

2 Answers

Wrap the column name in square brackets:

$sql = "SELECT [Kill] FROM tbl_pvporderview"; 
share|improve this answer

If you want to use reserved words as table or column names, you have 2 options:

use brackets (the SQL-Server's way): SELECT [Kill]

or double-quotes (the ANSI/ISO standard): SELECT "Kill"

Your whole statement would become:

SELECT [serial], [Kill] 
FROM tbl_pvporderview 
WHERE [Kill] > (?) 
ORDER BY [Kill] DESC ;
share|improve this answer
Of course, SELECT "Kill" would necessitate that QUOTED_IDENTIFIER is ON, which is the ANSI standard as mentioned. I recently inherited a database on SQL 2008 where it was still SET OFF. (Doh!) – Delux Aug 23 '12 at 13:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.