Write a script that will create a database. Include the creation of a user named user1 with a password of pword1. Save the script as create_database.sql.
We will help with homework, but you have to show effort. Posting just the problem is not showing any effort.
so i just do:
CREATE Database Data_1;
CREATE LOGIN user1
WITH PASSWORD = 'pword1';
GO
-- Creates a database user for the login created above.
CREATE USER user1 FOR LOGIN user1;
GO
That is pretty close. The thing that you need to do is to add the following before you create the user
USE Data_1
GO
That is because the user is a database level entity, and you want to create the user in the new database you created. IN order to do that, you have to make that database the current database.
1 Like
Ok thank you!!