Thursday, January 28, 2010

Creating a database from the command line

Question:
I am following the instructions in the ConfigControl guide to create a database using MSSQL from the command line but it is not working. What am I doing wrong?

Answer:
The earlier versions of the documentation are incorect. The correct way is like this:
Execute this set of code first to create the database

CREATE DATABASE ConfigControl ON PRIMARY (NAME = N'ConfigControl',
FILENAME = N'c:\ConfigControl.mdf', SIZE = 50MB, FILEGROWTH = 10%)
COLLATE Latin1_General_CI_AS;

Then Execute this set of code to create the user
CREATE LOGIN ConfigControlUser
WITH PASSWORD='ConfigControlpw',
DEFAULT_DATABASE = ConfigControl;
USE ConfigControl;
EXEC sp_changedbowner ConfigControlUser;

No comments:

Post a Comment