|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, September 08, 2007 1:30 AM
Points: 4,
Visits: 1
|
|
Hi all
(newbye)
I want write a script that can: 1° create a database (create database xxxx ..) 2° '??? add user ???' and grant him all privileges
How can do for 2° something as 'create user uid password' ?
thanks castore
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Tuesday, January 03, 2012 1:08 PM
Points: 89,
Visits: 15
|
|
I don't know that this is what you are looking for but the following will create a database, its schema, a table and add a user such that the user can login into the server and into the default database with permissions granted on the schema. Create Database GetStartedOn Primary( NAME = 'GetStartedDB_dat',Filename ='C:\Documents and Settings\admin\My Documents\SQL Server Management Studio\Projects\getstarteddb.mdf',SIZE = 5MB,MaxSize =25MB,FILEGrowth = 10%)LOG ON( NAME='GetStartedDB_log',FILENAME = 'C:\Documents and Settings\admin\My Documents\SQL Server Management Studio\Projects\getstarteddb.ldf',SIZE = 5MB,MaxSize =25MB,FILEGrowth = 10%)GO Create Schema newdbs Create Table EmployeeSummary( EmpID int Identity(1,1) Primary Key,EmployeeFirstName varchar(50),EmployeeLastName varchar(50),EmployeeBirthDate smalldatetime,EmployeeNumberofChildren int,EmployeeBankBalance Money)GO CREATE LOGIN LetMeStartWITH PASSWORD = 'weneedtologinnow'USE GetstartedCREATE USER Geton FOR LOGIN LetmestartWITH DEFAULT_SCHEMA = newdbsgo GRANT Select, INSert, Update On Schema::newdbs TO GetonGO
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, September 08, 2007 1:30 AM
Points: 4,
Visits: 1
|
|
Thanks very very mutch Keith. I shall try soon
|
|
|
|