I'm trying to create a script that will create a user account and then associate that user to the DB's for that user.
I have the following to create it but how do you have the script ask for the User name prior to creating the user.
USE [master]
GO
CREATE LOGIN [DOMAIN\USERNAME] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
USE [DB]
GO
CREATE USER [DOMAIN\USERNAME] FOR LOGIN [DOMAIN\USERNAME]
GO
USE [DB]
GO
ALTER USER [DOMAIN\USERNAME] WITH DEFAULT_SCHEMA=[DOMAIN\USERNAME]
GO
USE [DB]
GO
CREATE SCHEMA [DOMAIN\USERNAME] AUTHORIZATION [DOMAIN\USERNAME]
I have the following to create it but how do you have the script ask for the User name prior to creating the user.
USE [master]
GO
CREATE LOGIN [DOMAIN\USERNAME] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
USE [DB]
GO
CREATE USER [DOMAIN\USERNAME] FOR LOGIN [DOMAIN\USERNAME]
GO
USE [DB]
GO
ALTER USER [DOMAIN\USERNAME] WITH DEFAULT_SCHEMA=[DOMAIN\USERNAME]
GO
USE [DB]
GO
CREATE SCHEMA [DOMAIN\USERNAME] AUTHORIZATION [DOMAIN\USERNAME]