Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 Login user mapping does not persist

Tags:

sql-server

I am trying to grant a domain user to SQL Server 2008. This user should be able to login to the DB using server management studio, and run PowerShell scripts doing SELECT queries to a database. My problem is my settings does not persist.

In server management studio, I right click on Security->Logins->right click on ->Properties->User mappings-> tick my database which happens to be the first one, granted 'db_datareader' and 'public'. Click OK.

No error pops up. But when I check the user mappings again, my database is no longer ticked! What have I missed? Really puzzled... must be something very simple...

enter image description here

--update--:

soved: deleted the login+user, added them back,and the rest.. now ok. many thx!

like image 329
user1866880 Avatar asked Feb 20 '13 14:02

user1866880


2 Answers

It happens sometimes when user has no connect permission or the permission has been revoked.

Grant connect to [user]
like image 65
user3951476 Avatar answered Nov 06 '22 06:11

user3951476


use master;
GO

create login [<domain\user>] from windows;
GO

use [<yourdb>];
GO

create user [<domain\user>] for login [<domain\user>];
GO

ALTER ROLE db_datareader ADD MEMBER [<domain\user>];
GO
like image 42
muhmud Avatar answered Nov 06 '22 04:11

muhmud