How To Create a User Name in a Database?
Submitted by: AdministratorUser names are security principals at the database level. If you want to allow a login name to access a specific database, you need to create a user name in that database and link it to the login name.
Creating a user name can be done by using the "CREATE USER" statement as shown in this tutorial exercise:
-- Login with "sa"
-- Create a login
CREATE LOGIN ggl_Login WITH PASSWORD = 'IYF'
GO
-- Select a database
USE GlobalGuideLineDatabase;
GO
-- Create a user and link it to a login
CREATE USER ggl_User FOR LOGIN ggl_Login;
GO
Login name "ggl_Login" should be able to access database "GlobalGuideLineDatabase" through user name "ggl_User".
Submitted by: Administrator
Creating a user name can be done by using the "CREATE USER" statement as shown in this tutorial exercise:
-- Login with "sa"
-- Create a login
CREATE LOGIN ggl_Login WITH PASSWORD = 'IYF'
GO
-- Select a database
USE GlobalGuideLineDatabase;
GO
-- Create a user and link it to a login
CREATE USER ggl_User FOR LOGIN ggl_Login;
GO
Login name "ggl_Login" should be able to access database "GlobalGuideLineDatabase" through user name "ggl_User".
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Find Out What Is the Default Collation in a Database? |
☺ | How To Convert a Numeric Expression from One Data Type to Another? |
☺ | How to Create a View using Data from Another View? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | What Is a Subquery in a SELECT Query Statement in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Sybase Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |