July 10, 2007 at 1:18 am
Hi,
Does anyone perhaps have a script that takes a file and puts it in a different directory and then renames the old file.
IC
July 10, 2007 at 1:33 am
I dont have a script but the commands are as given below.
move <<SOURCEpath>>\filename <<DESTINATIONPATH>>\filename
rename <<SOURCEPATH>>\filename filename
the first will move the file to the destination location adn the second will rename your file. You have to change the path alone.
Cheers,
Sugeshkumar Rajendran
SQL Server MVP
http://sugeshkr.blogspot.com
July 10, 2007 at 10:46 pm
Hi,
Agree with Sugesh. And if you are planning to do it from sql server, then use xp_cmdshell to execute the above commands.
But you will require sysadmin fixed role to execute this command. Which is risky as far as security of your database is concerned.
Thanks
Sachin
July 11, 2007 at 8:13 am
I use stored procedures to move my files around with my SQL Servers.
They look something like
CREATE PROCEDURE [dbo].[msp_copy_Server_SQL_Full_Daily_Backups]
AS
DECLARE @command varchar(100)
DECLARE @location varchar(30)
DECLARE @destination varchar(41)
DECLARE @switches varchar(6)
DECLARE @day char(9)
SET @day = DATENAME(Weekday, GETDATE())
PRINT @day
SET @location = '\\Server_Name\Folder\*.*'
SET @destination = '\\Destination_Server_Name\Destination_Folder\'
SET @switches = '/E/H/Y'
SET @command = 'xcopy' + ' ' + @location + ' ' + @destination + @day +' ' + @switches
EXEC master..xp_cmdshell @command
July 11, 2007 at 9:18 am
Hi all,
Don't you have to detach database prior to moving files and then re-attach them back from new location ?
July 11, 2007 at 11:33 am
IF you are moving actual database files, that's true. However, if these are flat files, there's no such constraint.
July 11, 2007 at 11:10 pm
You might want to check out the FileSystemObject and the File objects in VBScript. There are lots of methods and properties that will give you more options. And of course you can run the script in a job.
Regards,
Rubes
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply