Groups | Blog | Home
all groups > sql server new users > june 2005 >

sql server new users : Syntax Question


HartAch
6/2/2005 9:23:17 AM
Just converted by website from Access to SQL. The below code works fine in
Access, but I am getting an error in SQL

strSQL = "SELECT Count(Status) as 17LCD FROM Monitors Where left(mSize,2) =
'17' and Type='LCD'"
rs.Open strSQL, conn, 3, 3

Here is the error

Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1: Incorrect syntax near '17'.
/inv/monitors.asp, line 60


Any ideas?


HartAch
6/2/2005 11:06:00 AM
Figure it out. Had to change 17LCD to LCD17


[quoted text, click to view]

Hugo Kornelis
6/2/2005 10:08:20 PM
[quoted text, click to view]

Hi HartAch,

If you want to give your column a name that doesn't follow the rules for
identifier names, then enclose it in quotation marks:

SELECT Count(Status) as "17LCD"
FROM Monitors
WHERE LEFT (mSize,2) = '17'
AND TYPE = 'LCD'

Best, Hugo
--

AddThis Social Bookmark Button