I have created 10 database of 'Northwind' for training purpose. Suppose I have 10 students, so databases are Northwind_Student1,Northwind_Student2 etc. I wo开发者_开发技巧uld like to create separate login for each pupil, so that Student1 can only see(or can access) the data base 'Northwind_Student1'. How can I accomplish this using T-SQL or SSMS 2008 ?
You can create different users for different databases and assign permissions like below. It's for SQL 2008, but it will be same for 2005 also :
In SSMS, expand the Security
tree of the server in Object Explorer and right-click Logins
to choose New Login...
, then add as many as needed.
Then in the Security
tree of each individual database, add the login as a user of that db and grant appropriate rights.
Create 10 different logins and assign each to the database it can access.
CREATE LOGIN yourloginname WITH PASSWORD = 'yourpassword'
精彩评论