Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
This article shows how to move a FILESTREAM-enabled database.
Note
The examples in this topic require the Archive database that is created in Create a FILESTREAM-Enabled Database.
To move a FILESTREAM-enabled database
In SQL Server Management Studio, select New Query to open the Query Editor.
Copy the following Transact-SQL script into the Query Editor, and then select Execute. This script displays the location of the physical database files that the FILESTREAM database uses.
USE [Archive] GO SELECT type_desc, name, physical_name from sys.database_files;Copy the following Transact-SQL script into the Query Editor, and then select Execute. This code takes the
Archivedatabase offline.USE [master] EXEC sp_detach_db [Archive]; GOCreate the folder
C:\moved_location, and then move the files and folders that are listed in step 2 into it.Copy the following Transact-SQL script into the Query Editor, and then select Execute. This script sets the
Archivedatabase online.CREATE DATABASE [Archive] ON PRIMARY ( NAME = Arch1, FILENAME = 'c:\moved_location\archdat1.mdf'), FILEGROUP FileStreamGroup1 CONTAINS FILESTREAM( NAME = Arch3, FILENAME = 'c:\moved_location\filestream1') LOG ON ( NAME = Archlog1, FILENAME = 'c:\moved_location\archlog1.ldf') FOR ATTACH; GO
See also
- Attach a database
- Detach a database
- Database Detach and Attach (SQL Server)
- CREATE DATABASE (SQL Server Transact-SQL)
- Configure File System Permissions for Database Engine Access