MS SQL Server Concepts and Programming Question: Download Questions PDF
How To Verify a User name with SQLCMD Tool?
Answer:
The quickest way to verify a user name in a database is probably to use the SQLCMD tool. You can connect to the server, select the database, and check which user name is linked the current login name as shown below.
Start a command window and enter the following command:
C:>SQLCMD -S LOCALHOSTSQLEXPRESS -U ggl_Login -P IYF
1> USE GlobalGuideLineDatabase;
2> GO
Changed database context to 'GlobalGuideLineDatabase'.
1> PRINT User_Name();
2> GO
ggl_User
This shows user "ggl_User" in database "GlobalGuideLineDatabase" is linked to login name "ggl_Login".
Start a command window and enter the following command:
C:>SQLCMD -S LOCALHOSTSQLEXPRESS -U ggl_Login -P IYF
1> USE GlobalGuideLineDatabase;
2> GO
Changed database context to 'GlobalGuideLineDatabase'.
1> PRINT User_Name();
2> GO
ggl_User
This shows user "ggl_User" in database "GlobalGuideLineDatabase" is linked to login name "ggl_Login".
Download MS SQL Server Interview Questions And Answers
PDF
Previous Question | Next Question |
How To Find the Login Name Linked to a Given User Name? | How To Change the Name of a Database User? |