Created
January 28, 2019 19:47
-
-
Save petesql/c84bf6a530b5eaca51e05f1765926feb to your computer and use it in GitHub Desktop.
attach_database_without_log
This file contains 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
CREATE DATABASE [funky_db] | |
ON ( NAME = funkydb_data, FILENAME = 'c:\sql\funkdata.mdf' ) | |
LOG ON ( NAME = funkydb_log, FILENAME = 'c:\sql\funklog.ldf') | |
USE [funky_db] | |
GO | |
CREATE TABLE [funky_people] (firstName VARCHAR(64), surname VARCHAR(64), dateofbirth DATE, funkLevel INT) | |
INSERT INTO [funky_people] VALUES ('funk','master','1969-01-01',100) | |
SELECT * | |
FROM [funky_people] | |
-------------------------------------------------------------------------------------------------------------- | |
USE [master] | |
GO | |
CREATE DATABASE [funky_db] ON | |
( FILENAME = N'C:\sql\funkdata.mdf' ) | |
FOR ATTACH | |
GO | |
USE [master] | |
GO | |
EXEC sp_attach_single_file_db | |
@dbname='funky_db', | |
@physname=N'c:\sql\funkdata.mdf' | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment