SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Grant db_datareader database role to a user for a readonly database


Grant db_datareader database role to a user for a readonly database

Author
Message
gary1
gary1
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4718 Visits: 2254
Hi,

I have configured log shipping for a database Mydb and the secondary is in Standby mode.

Now I have created a login called scott on secondary instance and trying to map that login to the standby mode database. But I'm getting the below error:


TITLE: Microsoft SQL Server Management Studio
------------------------------

Create failed for User 'scott'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.2531.0+((Katmai_PCU_Main).090329-1015+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+User&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

Failed to update database "Mydb" because the database is read-only. (Microsoft SQL Server, Error: 3906)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.00.2531&EvtSrc=MSSQLServer&EvtID=3906&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------


Please advice
Steve Jones
Steve Jones
SSC Guru
SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)

Group: Administrators
Points: 143878 Visits: 19424
You cannot make changes to a db in standby mode.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
gary1
gary1
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4718 Visits: 2254
You cannot make changes to a db in standby mode.


Then how a user can query that standby mode database? Because log shipping says, users can query the database if we configure log shipping secondary in a standby mode.Please advice..

My requirement is to logship the primary database to a secondary instance on nightly basis and give access to user on secondary database in business hours to query that database. I mean the restore job on secondary will run from 7pm to 7am.

from the link http://msdn.microsoft.com/en-us/library/ms189970.aspx

Standby mode:

Leave the secondary database in STANDBY mode. This mode will allow read-only operations to be performed on the database


Thanks
GilaMonster
GilaMonster
SSC Guru
SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)

Group: General Forum Members
Points: 219789 Visits: 46279
Existing users can query the log shipping secondary.
You cannot create new users in the secondary because that's a change and the database is read-only (no changes permitted)

You can create the user on the primary and the log shipping will take it over to the secondary. Make sure if you're also creating a login that you explicitly specify the SID

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


gary1
gary1
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4718 Visits: 2254
Existing users can query the log shipping secondary.

You cannot create new users in the secondary because that's a change and the database is read-only (no changes permitted)

You can create the user on the primary and the log shipping will take it over to the secondary. Make sure if you're also creating a login that you explicitly specify the SID


without creating a login, how we can create a user? because if we go to a database and try to create a user, then it will ask a login name right? So we must need to create login first in order to create a user right?

Make sure if you're also creating a login that you explicitly specify the SID


Could you please explain me the above a bit more..

Thanks
Steve Jones
Steve Jones
SSC Guru
SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)

Group: Administrators
Points: 143878 Visits: 19424
CREATE USER: http://msdn.microsoft.com/en-us/library/ms173463.aspx

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
gary1
gary1
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4718 Visits: 2254
Thanks,

It's clear that we must need to create login in order to create a user.

But Is that must to create a user on Primary production Database, in order to access the log shipped standby database on secondary for that user?

In that case we are giving access to Production database unnecessarily. Because the user actually do need access to Production database. He only required access to the secondary database so that he can query that database instead of Prod.

Please advice
Steve Jones
Steve Jones
SSC Guru
SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)

Group: Administrators
Points: 143878 Visits: 19424
You create a login and user on the source system.

You then migrate that login to the new system (the user will come through log shipping) using the same SPID.

This should help: http://support.microsoft.com/kb/246133

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Robert Davis
Robert Davis
SSCertifiable
SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)

Group: General Forum Members
Points: 6486 Visits: 1632
You can create a user without a login in SQL Server 2005 and newer. However, uyou can se these steps to simplify it for you:

1. Create login on production server
2. Create user in database mapped to login
3. Drop login on production server
4. Grant any required permissions to user in database
5. Create login on log shipping standby server
- a. If a SQL authenticated login, create login while specifying SID from production machine
- b. If Windows auth. login, create login without specifying SID
6. Make sure log shipping jobs have completed one full run since completion of step 4



My blog: SQL Soldier
Twitter: @SQLSoldier
My book: Pro SQL Server 2008 Mirroring
Microsoft Certified Master, SQL Server MVP
Database Engineer at BlueMountain Capital Management
gary1
gary1
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4718 Visits: 2254
You create a login and user on the source system.

You then migrate that login to the new system (the user will come through log shipping) using the same SPID.


But we do not want to create these users in Source production instance. Is there any way to create the logins and give access to standby mode database on secondary?

Thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search