Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    47

    Question Unanswered: Stored Procedure Query

    Hi,

    I have a query in Stored procedures...See if u could help me...

    I am using two Databases Cobank and BR0001

    which are on 2 different machines....

    I am writing stored procedures in Cobank

    In that stored procedure I m writing a query to access a table in BR0001

    So do u know how to proceed?

    I tried by passing servername as a parameter to stored proc.



    CREATE PROCEDURE ViewBranchDetail
    @localDBName as nvarchar(20)
    @servername as nvarchar(200)
    AS
    exec('Select * from opendatasource ( '''+@servername+''' ) . '''+@localDBName+'''..BranchDetail' )


    exec('Select * from opendatasource (''SQLOLEDB'''+','+''' Data Source=localhost;Initial Catalog=BR0001;Integrated Security=True )'''+ '..BranchDetail' )
    GO

  2. #2
    Join Date
    Apr 2008
    Location
    Along the shores of Lake Michigan
    Posts
    242
    Cross-posting is verboten. Fragments responses and wastes people's time.

    http://www.dbforums.com/microsoft-sq...ored-proc.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •