sproc using linked server without linked server validation

  • I want to create a linked server. I then want to create a sproc using that linked server, however in my scenario the linked server will not be available. Lets say the sql service for the linked server is turned off at the time i want to create the sproc.

    Is there away to tell SQL db engine to NOT verify anything about the linked server. See example below.

    sp_addlinkedserver myserver

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE PROCEDURE mysproc

    AS

    BEGIN

    select * from myserver.mydb.dbo.mytable

    END

    GO

    Jimmy

    "I'm still learning the things i thought i knew!"
  • No way, AFAIK.

    You could do that with dynamic sql:

    CREATE PROCEDURE mysproc

    AS

    BEGIN

    EXEC ('select * from myserver.mydb.dbo.mytable')

    Not exactly what you're after, but could work. Another possible solution is creating a loopback linked server (linked server to the same instance you're working on), given that you can create the database you will find in production.

    Hope this helps

    Gianluca

    -- Gianluca Sartori

Viewing 2 posts - 1 through 1 (of 1 total)

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