asked 121k views
4 votes
Write a script that creates a user-defined role name HRAdmin with the password 'HRR3p!4' that has the default database as FlughafenDB_v2 and has the Check Expiration and Check Policy turned off.

asked
User SunnyRed
by
8.2k points

1 Answer

5 votes

Sure, here's the script to create a SQL Server login with the user-defined role HRAdmin:

USE master;

GO

CREATE LOGIN HRAdmin WITH PASSWORD = 'HRR3p!4';

GO

USE FlughafenDB_v2;

GO

CREATE USER HRAdmin FOR LOGIN HRAdmin;

GO

ALTER ROLE db_datareader ADD MEMBER HRAdmin;

ALTER ROLE db_datawriter ADD MEMBER HRAdmin;

GO

ALTER LOGIN HRAdmin WITH CHECK_EXPIRATION = OFF;

ALTER LOGIN HRAdmin WITH CHECK_POLICY = OFF;

This script creates a new SQL Server login named HRAdmin with the password 'HRR3p!4'. It then creates a new user for this login in the FlughafenDB_v2 database, adds the new user to the db_datareader and db_datawriter roles, and turns off the Check Expiration and Check Policy options.

Please make sure to change the password to a secure one, and to modify the script based on your specific requirements.

answered
User Shmwel
by
8.4k points