How to attach existing SQL-users to new Database

BrianResen
Member Posts: 9
As part of a go-live senario on SQL 2005, I'm trying to find a easy way to copy the userlogin from one database (systemstest DB) to another (Go-live DB).
I have a systemstest-database and a future Go-live database on the same SQL2005 server. As part of test 70 users have been created with acces to the testdatabase. These 70 userlogin's I now need to give the same access to the Go-live database.
It would have to be a nested SQL query listing the userID's from the testDB and the granting the same permissions to the Go-liveDB.
I just don't know how to put this into SQL-statments.
Are there any one here that can help me out :?:
I have a systemstest-database and a future Go-live database on the same SQL2005 server. As part of test 70 users have been created with acces to the testdatabase. These 70 userlogin's I now need to give the same access to the Go-live database.
It would have to be a nested SQL query listing the userID's from the testDB and the granting the same permissions to the Go-liveDB.
I just don't know how to put this into SQL-statments.
Are there any one here that can help me out :?:
>>None but a fool worries about things they cannot influence...<< - Samuel Johnson
0
Comments
-
Hi,
well, once I had a similar issue, and I solved it with this script:declare @userid varchar(20), @tsql varchar(1000) declare user_cur cursor for select [User ID] from Test.dbo."User" open user_cur fetch next from user_cur into @userid while @@fetch_status = 0 begin set @tsql = ' use [master] go CREATE LOGIN [' + @userid + '] WITH PASSWORD = '''', CHECK_POLICY = OFF go use [Navision] go CREATE USER [' + @userid + '] FOR LOGIN [' + @userid + '] go ' print @tsql fetch next from user_cur into @userid end close user_cur deallocate user_cur
This generates a script to create logins/users on basis of the NAV table "User"; you could do it similar with a list e.g. from "syslogins" etc..
But you could also transfer logins e.g. from one SQL instance to another using the feature provided here: http://support.microsoft.com/kb/246133
Hope this helps you.
Regards,
JörgJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
P.S.: Please regard that the "Password" with the TSQL is left empty!Jörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
Well, I don't need to recreate the users on the SQL-server. I just need to attach a new database to the "User mapping", but for about 70 or so userID's. Therfore my need for a scripting solution... O:)>>None but a fool worries about things they cannot influence...<< - Samuel Johnson0
-
In SQL Server management studio. In Security->Login tree. On object explorer detail windows elect all the users right click and seelct scrip login ->Create->New query editor.
Copy and paste it into the other box and run it.
You only need to do this for SQL db users. For windows. After you restore the backup. WHen you synchronize Nav the windows users will be added to SQL automatically.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions