PRB: An Error Message Occurs With a Distributed Query That Has A Named Instance (252225)
The information in this article applies to:
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q252225 SYMPTOMS
When you use a distributed query that has a SQL Server 2000 named instance with an OpenRowset function like the following:
Select * from OpenRowset ('SQLOLEDB',[machineName\Shiloh];'sa';'', 'Select * from [pubs].[dbo].[jobs]')
this error message occurs:
-- [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'machineName\Shiloh'.
When you use four part names, or an Openquery with a named instance, you must use square brackets. For example:
However, the Openrowset function does not accept square brackets.
CAUSE
This is by design.
In the OpenRowset case example, the server name is really the DATASOURCE OLE DB Connection property. For the SQLOLEDB provider this happens to be the name of the server, which is syntactically a string. Brackets ([]) do not quote anything with strings because they are used for quoting identifiers, a different syntactic construct.
WORKAROUND
Do not use square brackets with named instances with the OpenRowset function.
Modification Type: | Major | Last Reviewed: | 11/5/2003 |
---|
Keywords: | kbprb KB252225 |
---|
|