Lee, The select statement is very valid and so is: SELECT 'Hello World!' as 'My first SQL Statement' -or- SELECT answer = 2+3
Really, try it. Anyway... I was sent the correct answer and was very surprised in that the syntax is indeed valid on some servers, however the ANSI standard is single quotes for all string literals and that these other drivers/servers handled string literals with either single or double quotes on a somewhat random basis...bizzare. Perl DBI thinks any double quoted string must be a column or table name ( [ and ] are preferred, but double quotes are still acceptable). The problem is that these other apps let the coder use that non-standard syntax and it works. I guess we will have to retrain the folks who generated this stuff. Thanks anyway. Question answered. James -----Original Message----- From: JupiterHost.Net [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 18, 2005 6:49 PM To: [email protected] Subject: Re: Double quotes in select statement throw an error Moosmann, James wrote: > Nope, same results, Here is a simple example: > > Is the syntax invalid? > > use DBI; > my $dbh = DBI->connect('dbi:ODBC:somedb','',''); > my $qs = $dbh->quote( "SELECT \"Rows returned: \" "); Why are you quoting the entire query as a string? > $dbh->do($qs); Use a valid query: $dbh->do("SELECT \"valid column\" FROM \"valid table\"") ... > print $dbh->errstr; > > ---RESULT--- > DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL > Server]Invalid column name 'Rows returned: '. (SQL-42S22) err, at the risk of sounding pedantic or sarcastic, it would appear there is no column named "Rows returned: ", so I'd say yes, the syntax is invalid... I'm not a Microsoft user (thank the Lord!!!) but even Bill Gates should be able to understand that error :) Lee.M
