This section describes how to create a new login user and grant full permission to a database in SQL Server.
In order to do some tests on PreparedStatement, I created a new login user, "Herong", and granted full permission
to "Herong" to use database, AdventureWorksLT:
C:\>sqlcmd -S localhost -U sa -P HerongYang
1> -- Set AdventureWorksLT as the current database
2> USE AdventureWorksLT;
3> GO
Changed database context to 'AdventureWorksLT'.
1> -- Create a new server login name: Herong
2> CREATE LOGIN Herong WITH PASSWORD = 'TopSecret'
3> GO
1> -- Create a new database user linked to the login name
2> CREATE USER Herong FOR LOGIN Herong;
3> GO
1> -- Grant database ALTER permision to the user
2> GRANT ALTER To Herong;
3> GO
1> -- Grant database CONTROL permision to the user
2> GRANT CONTROL To Herong;
3> GO
Here is what I did to test this new login name and user: Herong
C:\>sqlcmd -S localhost -U Herong -P TopSecret
1> -- Set AdventureWorksLT as the current database
2> USE AdventureWorksLT;
3> GO
Changed database context to 'AdventureWorksLT'.
1> -- Create a new table
2> CREATE TABLE Test (ID INT);
3> GO
1> -- Drop the table
2> DROP TABLE Test;
3> GO
Tests looked good to me. New login user, Herong, has enough permission to use database AdventureWorksLT.