John Jayaseelan (jo*************@caravan-club.co.uk) writes:
The following parameter query resulted the error below. Is the following
syntax correct?
select * from branch where branch_code = ?
Depends on which context you issued it in. It is not legal T-SQL. If you
run this from ISQL, which uses DB-Library that does not intercept the
SQL string, you get:
Msg 170, Level 15, State 1, Server KES-METS-, Line 1
Line 1: Incorrect syntax near '?'.
But if you run it from Query Analyzer, you get a more puzzling mesage:
[Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error
Note here that it does not say [SQL Server]. So this message comes from
the ODBC driver, because in the ODBC syntax, the ? is a special token
for a parameter holder. I don't the ODBC syntax well, so I cannot say
whether you can actually use this syntax successfully from QA. Normally,
you use this syntax when you pass SQL statements from application code.
--
Erland Sommarskog, SQL Server MVP,
so****@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp