![]() ![]() WHERE dbid IN ( SELECT dbid FROM ĮLSE + CONVERT ( VARCHAR ( 10 ), fileid ) (I preach everyone against using cursor. NOT IN ( 'master', 'tempdb', 'msdb', 'model' ) IN ( 'master', 'tempdb', 'msdb', 'model' )Īll ONLINE databases attached to the drives, except for system databases: Alert if there is any system database on the specific Script 1 - Create list of database files on the E: and F: drivesĪttached to the drives regardless of the database status: The drive letters in all scripts, so you can replace this for your particular server. To make this easier to see I have highlighted To the same location after the replacement. In my examples, the E:Īnd F: drives need to be replaced and databases need to be detached and reattached In the following examples I am not using a parameter to hold the drive letters,īecause I didn't want to use dynamic SQL or create a SP. Old drives with new drives, see the example below after the 3rd script). Two scripts (and you may use the third script as a base, modifying it by replacing Depending on what you need to accomplish, you may not needįor example, if you want to clone your entire disk and reattach everything backĪfter the cloning, you will use all 3 scripts if your goal is to move databasesįrom an existing drive to a new one (different letter), you may need only the first ![]() The goal is to find the specific databases, detach them and attach them to the Script 3 - The attach commands to attach back the databases listed in 1,. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |