Friday, March 23, 2012

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.not sure about this but try using linked server.|||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.|||try

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

No comments:

Post a Comment