Last post Oct 21, 2019 09:10 AM by Yang Shen
None
0 Points
2 Posts
Oct 18, 2019 01:24 PM|Gowtham Jaisankar|LINK
Hi All,
What is the T-SQL Query to create a new user and how to give access in T-SQL
All-Star
48490 Points
18070 Posts
Oct 18, 2019 05:12 PM|PatriceSc|LINK
Hi,
Seems you are looking for https://docs.microsoft.com/en-us/sql/t-sql/statements/create-user-transact-sql?view=sql-server-ver15
You could then add this user to the db_datareader/db_datawriter roles:
https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/database-level-roles?view=sql-server-ver15
You create a user so that your web app can read and write to the application db ? Some more context could perhaps help to better understand which level of information you need.
Contributor
3140 Points
983 Posts
Oct 21, 2019 09:10 AM|Yang Shen|LINK
Hi Gowtham,
Gowtham Jaisankar What is the T-SQL Query to create a new user
You can refer to SQL Server Script to create a new user, the query should be like below:
CREATE LOGIN NewUserName WITH PASSWORD = 'password' GO
Gowtham Jaisankar how to give access in T-SQL
Maybe you could try the GRANT method in sql server which you can refer to Granting table level permissions in SQL Server for how to use it.
GRANT SELECT ON "dbo"."DatabaseName" TO "UserName"`
Hope this could help.
Best Regard,
Yang Shen
None
0 Points
2 Posts
Query to Create a User
Oct 18, 2019 01:24 PM|Gowtham Jaisankar|LINK
Hi All,
What is the T-SQL Query to create a new user and how to give access in T-SQL
All-Star
48490 Points
18070 Posts
Re: Query to Create a User
Oct 18, 2019 05:12 PM|PatriceSc|LINK
Hi,
Seems you are looking for https://docs.microsoft.com/en-us/sql/t-sql/statements/create-user-transact-sql?view=sql-server-ver15
You could then add this user to the db_datareader/db_datawriter roles:
https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/database-level-roles?view=sql-server-ver15
You create a user so that your web app can read and write to the application db ? Some more context could perhaps help to better understand which level of information you need.
Contributor
3140 Points
983 Posts
Re: Query to Create a User
Oct 21, 2019 09:10 AM|Yang Shen|LINK
Hi Gowtham,
You can refer to SQL Server Script to create a new user, the query should be like below:
Maybe you could try the GRANT method in sql server which you can refer to Granting table level permissions in SQL Server for how to use it.
Hope this could help.
Best Regard,
Yang Shen