|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 11:42 AM
Points: 133,
Visits: 438
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, October 09, 2012 10:36 AM
Points: 30,
Visits: 130
|
|
The script works well with one exception. If your logical name for the database files contains spaces, it will cause issues.
If you alter the stored procedure and enclose the logical name for the database file in double quotes, this fixes the issue. See below:
set @sql = 'ALTER DATABASE ' + @DbName + ' MODIFY FILE (NAME = "' + @LogicalName + '", FILENAME = "' + @NewPath + '")'
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, February 04, 2013 12:39 AM
Points: 95,
Visits: 347
|
|
Very good method.
I'm just not sure if I would want to be any one of the users connected to the DB while the script is run, since I will get killed 
Keep in mind this script will kill any connected users by setting the db to single user with SET SINGLE_USER WITH ROLLBACK IMMEDIATE
Yes, I know what's being meant, but that gave me laugh though
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, October 09, 2012 10:36 AM
Points: 30,
Visits: 130
|
|
LOL that is funny, I did not think about it that way.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, April 25, 2013 4:51 PM
Points: 13,
Visits: 24
|
|
Has anyone tested the script with using a unc path for the new target location rather than a "hard-coded" drive letter?
Ron
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, October 09, 2012 10:36 AM
Points: 30,
Visits: 130
|
|
| Easily tested. But I have not
|
|
|
|
|
Keeper of the Duck
Group: Moderators
Last Login: Today @ 7:47 AM
Points: 6,584,
Visits: 1,796
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 11:42 AM
Points: 133,
Visits: 438
|
|
Johan van Tonder (8/26/2009)
Very good method. I'm just not sure if I would want to be any one of the users connected to the DB while the script is run, since I will get killed  Keep in mind this script will kill any connected users by setting the db to single user with SET SINGLE_USER WITH ROLLBACK IMMEDIATE Yes, I know what's being meant, but that gave me laugh though 
Bang your dead! I haven't laughed like this all week.
Jimmy
"I'm still learning the things i thought i knew!"
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 11:42 AM
Points: 133,
Visits: 438
|
|
Private Gripweed (8/26/2009) The script works well with one exception. If your logical name for the database files contains spaces, it will cause issues.
If you alter the stored procedure and enclose the logical name for the database file in double quotes, this fixes the issue. See below:
set @sql = 'ALTER DATABASE ' + @DbName + ' MODIFY FILE (NAME = "' + @LogicalName + '", FILENAME = "' + @NewPath + '")'
Thanks for pointing that out. I will update my script.
Jimmy
"I'm still learning the things i thought i knew!"
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 11:42 AM
Points: 133,
Visits: 438
|
|
rondad (8/26/2009) Has anyone tested the script with using a unc path for the new target location rather than a "hard-coded" drive letter?
Ron
I have not tested it like that.
Jimmy
"I'm still learning the things i thought i knew!"
|
|
|
|