Create View using Linked Server db in SQL Server Create View using Linked Server db in SQL Server sql sql

Create View using Linked Server db in SQL Server


You need to use the four part qualified name: linkedserver.database.schema.table

SELECT * FROM [1.2.3.4].Northwind.dbo.Customers

Here is an MSDN article about accessing object names.

You might want to try manually creating the view, rather than using the SQL Management tools:

CREATE VIEW [dbo].[sywx]AS    SELECT  *    FROM    [1.2.3.4].Atia.dbo.IpPbxDCRGO

I also recommend that you use a name, if possible, for the linked server rather than using the IP address.


Its a SQL Management Studio Issue. If you try to create the view using management studio NEW VIEW then you get that error incorrect syntax.

But if you use SQL Query:

CREATE VIEW [dbo].[viewname] AS     SELECT  *     FROM    [0.0.0.0].database.dbo.table GO 

then it will work.

To test you will see the view created when you refresh views. If you just do a select query from the view you will see the view return results.

But if you try to go into design mode for that view and try executing the design query the error will pop up again even though the view was successfully created.


If the linked server is set up, you just reference tables on it using a four-part qualified name:

linkedserver.database.schema.table

So if your linked server name is [0.0.0.0], you can reference a table as:

[0.0.0.0].database.schema.table