hidrau
asked on
how to create a user by script with as administrator of my database?
Hello guys
How could I create a user for my database as administrator, the same privileges as 'sa'
thanks
How could I create a user for my database as administrator, the same privileges as 'sa'
thanks
You can also grant permissions if required.
ASKER
Hello Pawan
I did this:
USE [master]
GO
CREATE LOGIN [alexhaifa] WITH PASSWORD=N'aqz1973', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
EXEC master..sp_addsrvrolemembe r @loginame = N'alexhaifa', @rolename = N'sysadmin'
GO
USE [SAAS_05091973_HERMES_ALEX HAIFA]
GO
CREATE USER [alexhaifa] FOR LOGIN [alexhaifa]
GO
When I login in my database with my created login, I noticed that I have access with all databases, I only want to have access to this:
SAAS_05091973_HERMES_ALEXH AIFA
where should I change? Default Database?
I did this:
USE [master]
GO
CREATE LOGIN [alexhaifa] WITH PASSWORD=N'aqz1973', DEFAULT_DATABASE=[master],
GO
EXEC master..sp_addsrvrolemembe
GO
USE [SAAS_05091973_HERMES_ALEX
GO
CREATE USER [alexhaifa] FOR LOGIN [alexhaifa]
GO
When I login in my database with my created login, I noticed that I have access with all databases, I only want to have access to this:
SAAS_05091973_HERMES_ALEXH
where should I change? Default Database?
Change USE [master] to USE [SAAS_05091973_HERMES_ALEX HAIFA] and then try.
You can use this to drop the user -
EXEC sp_dropuser 'UserName'
EXEC sp_dropuser 'UserName'
ASKER
I did that, my default database = [SAAS_05091973_HERMES_ALEX HAIFA]
But when I login on the sql, I can open all database and not only [SAAS_05091973_HERMES_ALEX HAIFA] :(
But when I login on the sql, I can open all database and not only [SAAS_05091973_HERMES_ALEX
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
nope :(
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot
NewUserName
Use [YourDBName]
GO
Open in new window