Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    Bangalore, India
    Posts
    27

    Angry Unanswered: Running the exec command on the second machine...

    I have a query to execute. The query is :-

    exec master.dbo.xp_fileexist @nFilePath

    This i can execute on the current machine.

    But how do i run this one on another machine.
    I took the machinename as a parameter and executed like :-

    exec @nMachinename.master.dbo.xp_fileexist @nFilePath

    But the exec command is not taking this...

    Giving me errors.

    Now how can i give the second machines name as a paramter and run dynamically????

    Thanks,
    Sandu.

  2. #2
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    not sure about this but try using linked server.

  3. #3
    Join Date
    Oct 2003
    Location
    Bangalore, India
    Posts
    27
    Okies..


    I got it...

    I have to set the value into a variable of the above mentioned query and then execute the variable...

    Anyway thanks...


    --Sandu.

  4. #4
    Join Date
    Oct 2001
    Location
    England
    Posts
    426
    try

    declare @sql nvarchar(1000)
    select @sql = 'exec ' + @nMachinename + '.master.dbo.xp_fileexist ''' + @nFilePath + ''''
    exec (@sql)

Posting Permissions

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