A Manic Developer's Place

Simple sql-server creation script

February 26, 2016

database

Create db, login and user….

--drop database mydb;
--drop user myuser;
--drop login myuser;

CREATE DATABASE [mydb] 
GO
ALTER DATABASE mydb MODIFY FILE 
( NAME = N'mydb' , SIZE = 102400KB , MAXSIZE = UNLIMITED, FILEGROWTH = 102400KB )
GO
ALTER DATABASE mydb MODIFY FILE 
( NAME = N'mydb_log' , SIZE = 1024KB , MAXSIZE = UNLIMITED , FILEGROWTH = 10%)
GO

USE [mydb]
CREATE LOGIN myuser 
    WITH PASSWORD    = N'xxxxxxxxx',
    CHECK_POLICY     = OFF,
    CHECK_EXPIRATION = OFF;
GO

CREATE USER myuser FROM LOGIN [myuser];
exec sp_addrolemember 'db_owner', 'mydb';
GO

ManicDev on Github

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/O d-pu s-:+++ a+ C+++ UL+++ P- L++ E--- W+++ N o-- K--? w++ O M+ V PS PE Y+ PGP t+ 5? X+ R tv- b+ DI- D++ G e+ h++ r++ z
------END GEEK CODE BLOCK------