sp_create_removable

  • I used sp_create_removable to create a db in local drive and detach it to a CD, but I can't attach it back since the files (in the CD-ROM) are not in local drive. Can someone tell me how to create a read-only db in CD?

    Thanks!

    David

  • There should be no problem as long as you pass the correct paths to sp_attachdb.

    I use this process to work both at home and at the office using 4 databases on a large USB drive. I detach the db's before moving the drive, and use the script below to reattach them once the drive is plugged into the appropriate USB port. The only problem I have is that the USB drive maps to a different drive letter on my home PC from my work PC and so I have to modify the script for each host.

    use master

    go

    EXEC sp_attach_db N'db1', N'F:\SQL\DATA\db1.mdf', N'F:\SQL\DATA\db1_Log.ldf'

    EXEC sp_attach_db N'db2', N'F:\SQL\DATA\db2.mdf', N'F:\SQL\DATA\db2_Log.ldf'

    EXEC sp_attach_db N'db3', N'F:\SQL\DATA\db3.mdf', N'F:\SQL\DATA\db3_log.ldf'

    EXEC sp_attach_db N'db4', N'F:\SQL\DATA\db4.mdf', N'F:\SQL\DATA\db4_log.ldf'

     

     


    Tony

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply