05 Laboratory FK
05 Laboratory FK
BT 502
1. Open/launch the Microsoft SQL Server 2017 from your Windows computer and use the default login
using Windows Authentication
2. Next, right-click the server instance name and select Properties to open the Property window.
3. From the property window, select the Security tab and enable the SQL User login to SQL Server by
selecting the SQL Server and Windows Authentication mode and click OK. SQL Server is configured for
mixed-mode login.
4. To create SQL Login, right-click the Security tab again and select New, then Login. The Login dialog box
shall appear.
11. To check the newly created login, expand the Security folder, and expand the Login folder.
13. We can now use the newly created Login. To do this, right-click the server instance name and select
Connect
Try to open/access the “demo” database in User1 login by expanding the Databases folder and expand
the “demo”. You will get an error like this. (See the image below)
In order to access it, you need to create a user for that database. To create a user, under the Windows
default login, expand the Databases, then expand demo. Expand the Security folder and right-click the
Users folder, then click New User
Put User1 as username, and locate the User1 in Login name.
To give permission, under the Windows default login, expand the Databases, then expand demo. Expand
the Security folder, right-click the Roles folder, then select New Database Role.
Under the General tab, create a user-defined role named db_demo_access. Then under the Securables
tab, click Search.
Click All objects belonging to the schema: then click dbo or the name of the database. Then, click OK.
We want to give the user-defined Role permission where he can only read and update the data from the
demo database. To do this, check the grant corresponding to SELECT and UPDATE. Then click OK