used named instances in queries

  • I am developing a view in server a that references several tables in server b. I setup a linked server to accomplish this.

    Server B is a named instance using SQl 2000.

    How can a hardcode a view in server a that references the named instance in server B?

    Easy if you know how.

    When the snows fall and the white winds blow,The lone wolf dies but the pack survives.

    Once you've accepted your flaws, no one can use them against you.

  • Are you asking or playing "I've got a secret?"

    We use the SQL Server client utility and set up an alias to the named instances. Then we can use that.

  • An easy way to demonstrate how.

    On the named instance, execute the following:

    
    
    USE Northwind
    GO
    SELECT *
    INTO AltCustomers
    FROM Customers

    Add your linked server pointing to the named instance.

    Create the following view (assuming the instance is MyServer\NamedInstance, alter as appropriate) on the server with the linked server connection. I created in Northwind to demonstrate:

    
    
    USE Northwind
    GO
    CREATE VIEW vw_AltCustomers
    AS
    SELECT *
    FROM [MyServer\NamedInstance].Northwind.dbo.AltCustomers

    Notice the use of brackets to specify the server with named instance. This particular example demonstrates the view is actually selecting from a table on the named instance, since there shouldn't be a table named AltCustomers normally in the Northwind database.

    K. Brian Kelley

    http://www.truthsolutions.com/

    Author: Start to Finish Guide to SQL Server Performance Monitoring

    http://www.netimpress.com/shop/product.asp?ProductID=NI-SQL1

    K. Brian Kelley
    @kbriankelley

  • Or make it easier and use the client network utility to set your own name to the instance name. Then use it as your server when setting up the linked server as described previously.

  • You folks are too helpful. I honestly had no clue.

    "I hope you enjoy your retirement as much as I will."

    When the snows fall and the white winds blow,The lone wolf dies but the pack survives.

    Once you've accepted your flaws, no one can use them against you.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply