11.16.2009

Create New User in SQL Server

Credit: Dr. Herong Yang [www.herongyang.com]

C:\>sqlcmd -S localhost -U sa -P xxxx

1> -- Set DBPMSPemasaran as the current database
2> USE DBPMSPemasaran;
3> GO
Changed database context to 'DBPMSPemasaran'.

1> -- Create a new server login name: PMSPemasaran
2> CREATE LOGIN PMSPemasaran WITH PASSWORD = 'xxxxx'
3> GO

1> -- Create a new database user linked to the login name
2> CREATE USER PMSPemasaran FOR LOGIN PMSPemasaran;
3> GO

1> -- Grant database ALTER permision to the user
2> GRANT ALTER To PMSPemasaran;
3> GO

1> -- Grant database CONTROL permision to the user
2> GRANT CONTROL To PMSPemasaran;
3> GO

Here is what I did to test this new login name and user: PMSPemasaran

C:\>sqlcmd -S localhost -U PMSPemasaran -P xxxxx

1> -- Set DBPMSPemasaran as the current database
2> USE DBPMSPemasaran;
3> GO
Changed database context to 'DBPMSPemasaran'.

1> -- Create a new table
2> CREATE TABLE Test (ID INT);
3> GO

1> -- Drop the table
2> DROP TABLE Test;
3> GO

0 comments:

 
Template by yummylolly.com