Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to create a user specific to database

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2008-08-18 : 14:25:44
I want to create an sql login user, specific to MYDatabase only.

Can you please help.

Thank you very much for the information

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-08-18 : 14:41:23
[code]
create login junk with
password='junk$junk'
,default_database = <Specific_Database>
go
use <Specific_Database>
create user junk
from login junk

go
--test login
go
drop user junk
go
drop login junk
[/code]
Then grant specific privs (SELECT, EXEC, etc) for the user in the database to whatever objects they need.
Alternatively, you can add them to a database role ie: db_datareader


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -