FIX: Correlated Subquery Can Fail With Trace Flag 204 EnabledID: Q158235
|
Microsoft SQL Server version 6.5 does not allow a correlated subquery in
the column list of a SELECT statement when trace flag 204 is enabled. When
this type of query is executed, the following error is encountered:
Msg 107, Level 15, State 1
The column prefix 'o' does not match with a table name or alias name used in the query.
To work around this problem, disable trace flag 204, and create a stored procedure that contains your query. This stored procedure can be run with trace flag 204 enabled, and it will produce the correct results. For SQL Enterprise Manager, you must disable this trace flag to use all features of the product.
Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.5. This problem has been corrected in U.S. Service Pack 2 for Microsoft SQL Server version 6.5. For more information, contact your primary support provider.
The following is an example of a query that fails with trace flag 204
enabled:
select LogOnSepDev = (select count(*) from sysusages us where us.dbid =
o.dbid and us.segmap = 4)
from sysdatabases o
Setup initialization could not be successfully completed. Isql.exe could not be executed. Please check the relevant .out file.
Creating 'sp_helpconstraint'.
Msg 107, Level 15, State 1. Procedure sp_helpconstraint, Line 513
The column prefix 'r' does not match with a table name or alias name used in the query.
SQL Server trace flags provide additional information about SQL Server operations or change certain behaviors, usually for backward compatibility. In general, trace flags should be used to temporarily work around a problem until a permanent solution is put in place. Although the information provided by trace flags can help you diagnose problems, keep in mind that trace flags are not part of the supported feature set. This means that future compatibility or continued use is not assured. In addition, your primary support provider, including Microsoft, will usually not have further information and will not answer questions regarding the trace flags or their output. In other words, the information provided in this section is to be used "as is."
Additional query words: SP1
Keywords : kbnetwork SSrvTran_SQL kbbug6.50 kbfix6.50.sp2
Version : 6.5
Platform : WINDOWS
Issue type :
Last Reviewed: April 3, 1999