Wednesday, March 7, 2012

Move DB users

Hi,
I have an already existing DB A, and I created new one B under the same SQL
Server registration. I want to transfer DB "Users" from a to B. How can I
do that? To make myself clear, I am not talking about "Logins"I assume that you are talking about moving logins from one server to
another. I have used this method many times and it works well.
HOW TO: Transfer Logins and Passwords Between Instances of SQL Server
http://www.support.microsoft.com/?id=246133
Keith
"SQLServerNewbee" <SQLServerNewbee@.discussions.microsoft.com> wrote in
message news:A4F45400-3FF6-4717-A9DE-D9E0266E20B2@.microsoft.com...
> Hi,
> I have an already existing DB A, and I created new one B under the same
SQL
> Server registration. I want to transfer DB "Users" from a to B. How can
I
> do that? To make myself clear, I am not talking about "Logins"|||No, Keith...I am trying to move Users from dB 'A' to dB 'B'. I know that we
can transfer logins...but how about Users
"Keith Kratochvil" wrote:

> I assume that you are talking about moving logins from one server to
> another. I have used this method many times and it works well.
> HOW TO: Transfer Logins and Passwords Between Instances of SQL Server
> http://www.support.microsoft.com/?id=246133
> --
> Keith
>
> "SQLServerNewbee" <SQLServerNewbee@.discussions.microsoft.com> wrote in
> message news:A4F45400-3FF6-4717-A9DE-D9E0266E20B2@.microsoft.com...
> SQL
> I
>|||This should serve as a start:
SELECT 'EXEC sp_grantdbaccess "' + name + '"'
FROM sysusers
WHERE isntname = 1
SELECT 'EXEC sp_adduser "' + name + '"'
FROM sysusers
WHERE issqluser = 1
Run above in source db and execute result in destination db. Above assumes s
ame user name as login
name. If that isn't the case, join sysusers to master..syslogins and pick th
e login name and use as
second parameter for the sp_ call. Also, this was a quickie, run tests etc a
nd make sure that is
work as expected.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"SQLServerNewbee" <SQLServerNewbee@.discussions.microsoft.com> wrote in messa
ge
news:51D4315F-93CE-429C-A13B-5B450E33BEA6@.microsoft.com...[vbcol=seagreen]
> No, Keith...I am trying to move Users from dB 'A' to dB 'B'. I know that
we
> can transfer logins...but how about Users
> "Keith Kratochvil" wrote:
>|||You aren't moving users -- they already exist. You have to grant database
access. Tibor's script should work for you.
Keith
"SQLServerNewbee" <SQLServerNewbee@.discussions.microsoft.com> wrote in
message news:51D4315F-93CE-429C-A13B-5B450E33BEA6@.microsoft.com...
> No, Keith...I am trying to move Users from dB 'A' to dB 'B'. I know that
we[vbcol=seagreen]
> can transfer logins...but how about Users
> "Keith Kratochvil" wrote:
>
same[vbcol=seagreen]
can[vbcol=seagreen]|||Hi Keith, Tibor,
I do not think permissions will be proper after this.. we need to reapply
permissions script... pls confirm
regards,
bharath
"Keith Kratochvil" wrote:

> You aren't moving users -- they already exist. You have to grant database
> access. Tibor's script should work for you.
> --
> Keith
>
> "SQLServerNewbee" <SQLServerNewbee@.discussions.microsoft.com> wrote in
> message news:51D4315F-93CE-429C-A13B-5B450E33BEA6@.microsoft.com...
> we
> same
> can
>|||Correct. You need to bring over permissions as well. Perhaps it is better to
let EM generate scripts
for this and extract the sp_adduser and GRANT commands from the generated sc
ripts...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Bharath" <Bharath@.discussions.microsoft.com> wrote in message
news:669D8883-F7FB-44CE-979B-9487FEEDCFCF@.microsoft.com...[vbcol=seagreen]
> Hi Keith, Tibor,
> I do not think permissions will be proper after this.. we need to reapply
> permissions script... pls confirm
> regards,
> bharath
> "Keith Kratochvil" wrote:
>

No comments:

Post a Comment