• Many thanks to Josep for the effort in creating the script, also to Henrik Staun Poulsen for augmenting the script with "move".

    To get Henrik's script working on my SQL 2000 server, I had to change the following line from this:

    SELECT @Move = @Move + 'MOVE ''' + NAME + ''' TO ''' + Physical_Name + ''', ' + CHAR(13)

    FROM sys.database_files

    to this:

    SELECT @Move = @Move + 'MOVE ''' + RTRIM(NAME) + ''' TO ''' + RTRIM(FileName) + ''', ' + CHAR(13)

    FROM dbo.sysfiles

    I also found that VARCHAR(MAX) was introduced for SQL 2005, so I adapted it to VARCHAR(8000) which is an assumption on my part as to length required, but it works for me as my path/filenames aren't overly long.

    DECLARE @Days INT, @WithMove INT, @WithStats INT, @Move VARCHAR(8000), @stats VARCHAR(8000)

    Regards,

    bitBIG