USE [master]
GO

/* For security reasons the login is created disabled and with a random password. */
/****** Object:  Login [user_pacsdbname]    Script Date: 5/28/2019 3:48:32 PM ******/
IF NOT EXISTS (SELECT name  
     FROM master.sys.server_principals
     WHERE name = 'user_pacsdbname')

BEGIN
CREATE LOGIN [user_pacsdbname] WITH PASSWORD=N'userpass', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
ALTER LOGIN [user_pacsdbname] ENABLE

-- Them quyen user cho db pacsdbname
USE [pacsdbname]
CREATE USER [user_pacsdbname] FOR LOGIN [user_pacsdbname]
ALTER ROLE [db_datareader] ADD MEMBER [user_pacsdbname]
ALTER ROLE [db_datawriter] ADD MEMBER [user_pacsdbname]
ALTER ROLE [db_owner] ADD MEMBER [user_pacsdbname]
END