Search code examples
sqldatabasesql-server-2000

Can I create a view that will query a table from another sql server on another server but same domain


I need to query a table from another SQL Server on a different server but same domain, but I am not sure how I will be able to do it.

I tried solution given in this answer Can I create view in my database server from another database server but it doesn't work for me as I got SQL Server 2000 (please don't hate :-) ).

When I try solution given then i get this error,

Line 23: Incorrect syntax near '-'.

which is because command is not compatible with SQL Server 2000.

Edit

SELECT * FROM AnotherServer.AnotherServerDatabase.Server.Table1 

Solution

  • you can link the servers and run cross server queries as long as you put the server name before the DB your running the query on.

    For example

    SELECT * FROM "linkedserver".dbo.aTable
    

    (without "" marks )

    bear in mind different server versions though. I run cross server queries from 2008 to 2000 servers and its a pain adapting :)