Creating Logins for Databases Restored to a Replacement SQL Server



Create.logins.sql

– Create source-server logins on target-server

USE Master
Go

DECLARE logincur CURSOR
FAST_FORWARD
FOR
SELECT [name], encryptedpassword, defaultdb,
deflanguage, sid, encryptopt
FROM Northwind..logins

DECLARE @loginame varchar(30),
@passwd nvarchar(128),
@defdb nvarchar(128),
@deflang nvarchar(128),
@sid varbinary(85),
@encryptopt varchar(30)

OPEN logincur

FETCH NEXT FROM logincur 
INTO @loginame, @passwd, @defdb, 
@deflang, @sid, @encryptopt

WHILE (@@fetch_status = 0)
BEGIN

EXEC master..sp_addlogin
@loginame, @passwd, @defdb,
@deflang, @sid, @encryptopt

FETCH NEXT FROM logincur 
INTO @loginame, @passwd, @defdb, 
@deflang, @sid, @encryptopt

END

CLOSE logincur
DEALLOCATE logincur
GO

Published with the express written permission of the author. Copyright 2001.

Pages: 1 2




Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |