Get Sqlserver and Windows Logins for Migration

Posted: April 1, 2008 in Scripts to use

——————————————————————
Windows Logins
——————————————————————

SELECT ‘EXEC sp_grantlogin @loginame = ”’ + loginname + ””

,’ EXEC sp_defaultdb @loginame = ”’ + loginname + ””

,’, @defdb = ”’ + dbname + ””

FROM syslogins

WHERE loginname NOT IN (‘BUILTIN\Administrators’)

AND isntname = 1

———————————————————————-
SQlserver Logins
———————————————————————-
–SQL Server User List

SET NOCOUNT ON

SELECT ‘EXEC sp_addlogin @loginame = ”’ + loginname + ””

,’, @defdb = ”’ + dbname + ””

,’, @deflanguage = ”’ + language + ””

,’, @encryptopt = ”skip_encryption”’

,’, @passwd =’

, cast(password AS varbinary(256))

,’, @sid =’

, sid

FROM syslogins

WHERE name NOT IN (‘sa’)

AND isntname = 0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s