For SQL code implementation of user creation, as well as switching between different users landing

Source: Internet
Author: User

--1, preparation work. Create two login names
Create Login Login1 with password= ' 123456 ';
Create Login Login2 with password= ' 123456 ';

--Create two user names U1 and U2 in the Studentcourse database and associate them with the two logins above, respectively
Use Studentcourse
Go
Create User U1 for Login Login1;
Create User U2 for Login Login2;

--2, fast switching users
--"View Current User"
Print Current_User;

--"Analog Access User: U1"
Execute as user= ' U1 ';
Print Current_User;

--"Switch back to dbo user"
Revert;
Print Current_User;

--"Analog Access User: U2"
Execute as user= ' U2 ';
Print Current_User;

--"Switch back to dbo user"
Revert;
Print Current_User;

--Delete the login and user name for the test
Drop Login Login1;
Drop Login Login2;
Drop User U1;
Drop User U2;

For SQL code implementation of user creation, as well as switching between different users landing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.