I have a linked server Remoteserver containing a table that holds file and folder names from a dir
When I am on the remote server I can run a built in procedure (xp_dirtree) and populate the 'files' table but what i need to do is to run a query from the local SQL server that does this:
- Delete all records from the [Files]table onRemoteserver
- Insert data that comes from the stored procedure: - INSERT [Remoteserver].[dbo].[files] (subdirectory,depth,isfile) EXEC master.sys.xp_dirtree '\\Fileserver\DBBackup',1,1;
- Select the 'subdirectory' column 
I tried some things using openquery and i am able to select existing records but unable to do the insert.
Any help is appreciated.
 
     
    