Created
March 22, 2014 08:40
-
-
Save nisar1/9703302 to your computer and use it in GitHub Desktop.
attach file + physical location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--atach file | |
CREATE DATABASE [SchoolDB] ON | |
( FILENAME = N'D:\SchoolDB.mdf' ), | |
( FILENAME = N'c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\SchoolDB_log.ldf' ) | |
FOR ATTACH | |
GO | |
--attach file | |
create database SchoolDB ON | |
( filename = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\SchoolDB.mdf') | |
for attach | |
go | |
-- know the physical files of db | |
SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1) | |
FROM master.sys.master_files | |
WHERE database_id = 1 AND file_id = 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment