Copying system DB's to a new server

  • malachyrafferty (4/20/2010)


    thanks all for help, i get a bit overly worried i might break something!

    the only service days are sundays. i like sundays at home 🙂

    Unfortunately it comes with the territory. I've done my share of off hours work so you really aren't going to get much sympathy from me or my family.

  • Shabba (4/20/2010)


    the only service days are sundays. i like sundays at home 🙂

    But they are normally double time 😉

    Not for those of us who are considered exempt from OT, which unfortunately is most of us in IT in the US. There are exceptions, but not a lot.

  • i get my fair share to as im generaly back and forward between the uk and eire, but i find once you show sundays are ok they aint half as afraid to ask the next time!

    i tend to pretend im religious - generally work s :w00t:

  • malachyrafferty (4/20/2010)


    i get my fair share to as im generaly back and forward between the uk and eire, but i find once you show sundays are ok they aint half as afraid to ask the next time!

    i tend to pretend im religious - generally work s :w00t:

    At a previous employer I upset a few people when I was on-call. I turned my pager off when I went into church on Sunday's and while I was out on the soccer field officiating youth soccer. My boss supported me, however, so nothing ever came of it.

  • Well I guess i'm one of the lucky (or unlucky) ones! On-call, overtime & 46 days leave a year here in the UK. Though I would gladly swap it all for a warmer climate... guess we can't have it all.

  • Shabba (4/20/2010)


    Well I guess i'm one of the lucky (or unlucky) ones! On-call, overtime & 46 days leave a year here in the UK. Though I would gladly swap it all for a warmer climate... guess we can't have it all.

    Where in the UK?

  • I'm based in the UK but would love the opportunity to work in the US... if only I could persuade my wife!

  • Be happy with your 46 days a year. Very typically, the standard vacation time in the USA is 15 days a year.

    Tim White

  • 2 Tim 3:16 (4/22/2010)


    Be happy with your 46 days a year. Very typically, the standard vacation time in the USA is 15 days a year.

    15 days?! are you kidding me? That sucks big time!

  • hi again

    ok i got everything moved over pretty easily, but i am now having some difficulties in ammending the sql users

    i have a user mbl, and when i try to update its users mappings it tells me ....

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

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

    ADDITIONAL INFORMATION:

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

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

    User, group, or role 'MBL' already exists in the current database. (Microsoft SQL Server, Error: 15023)

  • ok, i see that the users also copyed across already with the database restores,

    but should i delete and set them up again? as they do not show in \\security>logins ?

  • Hi,

    This is because a database user called 'MBL' already exisits in the database, you can check this by expanding databases, database_name, security, users.

    Once the user has been deleted you can script the user back again!

  • Did you create the logins manually or by script?

  • i havnt created any..

    the db users moved with the restore

  • Do you know how the sql login should be created in terms of permissions, passwords etc? If you do then just recreate the SQL login with the appropriate user mapping/role permissions etc. If you don't then run the script below against the old instance to script out the logins (make sure you remove all logins apart from 'MBL' otherwise these will be recreated on your new instance!)

    --logins and passwords between different versions of SQL Server and then assign logins to roles, follow these steps:

    --1. Run the following script on the source SQL Server.

    USE master

    GO

    IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL

    DROP PROCEDURE sp_hexadecimal

    GO

    CREATE PROCEDURE sp_hexadecimal

    @binvalue varbinary(256),

    @hexvalue varchar(256) OUTPUT

    AS

    DECLARE @charvalue varchar(256)

    DECLARE @i int

    DECLARE @length int

    DECLARE @hexstring char(16)

    SELECT @charvalue = '0x'

    SELECT @i = 1

    SELECT @length = DATALENGTH (@binvalue)

    SELECT @hexstring = '0123456789ABCDEF'

    WHILE (@i <= @length)

    BEGIN

    DECLARE @tempint int

    DECLARE @firstint int

    DECLARE @secondint int

    SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1))

    SELECT @firstint = FLOOR(@tempint/16)

    SELECT @secondint = @tempint - (@firstint*16)

    SELECT @charvalue = @charvalue +

    SUBSTRING(@hexstring, @firstint+1, 1) +

    SUBSTRING(@hexstring, @secondint+1, 1)

    SELECT @i = @i + 1

    END

    SELECT @hexvalue = @charvalue

    GO

    IF OBJECT_ID ('sp_help_revlogin_2000_to_2005') IS NOT NULL

    DROP PROCEDURE sp_help_revlogin_2000_to_2005

    GO

    CREATE PROCEDURE sp_help_revlogin_2000_to_2005

    @login_name sysname = NULL,

    @include_db bit = 0,

    @include_role bit = 0

    AS

    DECLARE @name sysname

    DECLARE @xstatus int

    DECLARE @binpwd varbinary (256)

    DECLARE @dfltdb varchar (256)

    DECLARE @txtpwd sysname

    DECLARE @tmpstr varchar (256)

    DECLARE @SID_varbinary varbinary(85)

    DECLARE @SID_string varchar(256)

    IF (@login_name IS NULL)

    DECLARE login_curs CURSOR STATIC FOR

    SELECT sid, [name], xstatus, password, isnull(db_name(dbid), 'master')

    FROM master.dbo.sysxlogins

    WHERE srvid IS NULL AND

    [name] <> 'sa'

    ELSE

    DECLARE login_curs CURSOR FOR

    SELECT sid, [name], xstatus, password, isnull(db_name(dbid), 'master')

    FROM master.dbo.sysxlogins

    WHERE srvid IS NULL AND

    [name] = @login_name

    OPEN login_curs

    FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb

    IF (@@fetch_status = -1)

    BEGIN

    PRINT 'No login(s) found.'

    CLOSE login_curs

    DEALLOCATE login_curs

    RETURN -1

    END

    SET @tmpstr = '/* sp_help_revlogin script '

    PRINT @tmpstr

    SET @tmpstr = '** Generated '

    + CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */'

    PRINT @tmpstr

    PRINT ''

    PRINT ''

    PRINT ''

    PRINT '/***** CREATE LOGINS *****/'

    WHILE @@fetch_status = 0

    BEGIN

    PRINT ''

    SET @tmpstr = '-- Login: ' + @name

    PRINT @tmpstr

    IF (@xstatus & 4) = 4

    BEGIN -- NT authenticated account/group

    IF (@xstatus & 1) = 1

    BEGIN -- NT login is denied access

    SET @tmpstr = '' --'EXEC master..sp_denylogin ''' + @name + ''''

    PRINT @tmpstr

    END

    ELSE

    BEGIN -- NT login has access

    SET @tmpstr = 'IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE [name] = ''' + @name + ''')'

    PRINT @tmpstr

    SET @tmpstr = CHAR(9) + 'CREATE LOGIN [' + @name + '] FROM WINDOWS'

    PRINT @tmpstr

    END

    END

    ELSE

    BEGIN -- SQL Server authentication

    EXEC sp_hexadecimal @SID_varbinary, @SID_string OUT

    IF (@binpwd IS NOT NULL)

    BEGIN -- Non-null password

    EXEC sp_hexadecimal @binpwd, @txtpwd OUT

    SET @tmpstr = 'CREATE LOGIN [' + @name + '] WITH PASSWORD=' + @txtpwd + ' HASHED'

    END

    ELSE

    BEGIN -- Null password

    SET @tmpstr = 'CREATE LOGIN [' + @name + '] WITH PASSWORD='''''

    END

    SET @tmpstr = @tmpstr + ', CHECK_POLICY=OFF, SID=' + @SID_string

    PRINT @tmpstr

    END

    FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb

    END

    IF @include_db = 1

    BEGIN

    PRINT ''

    PRINT ''

    PRINT ''

    PRINT '/***** SET DEFAULT DATABASES *****/'

    FETCH FIRST FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb

    WHILE @@fetch_status = 0

    BEGIN

    PRINT ''

    SET @tmpstr = '-- Login: ' + @name

    PRINT @tmpstr

    SET @tmpstr = 'ALTER LOGIN [' + @name + '] WITH DEFAULT_DATABASE=[' + @dfltdb + ']'

    PRINT @tmpstr

    FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb

    END

    END

    IF @include_role = 1

    BEGIN

    PRINT ''

    PRINT ''

    PRINT ''

    PRINT '/***** SET SERVER ROLES *****/'

    FETCH FIRST FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb

    WHILE @@fetch_status = 0

    BEGIN

    PRINT ''

    SET @tmpstr = '-- Login: ' + @name

    PRINT @tmpstr

    IF @xstatus &16 = 16 -- sysadmin

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''sysadmin'''

    PRINT @tmpstr

    END

    IF @xstatus &32 = 32 -- securityadmin

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''securityadmin'''

    PRINT @tmpstr

    END

    IF @xstatus &64 = 64 -- serveradmin

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''serveradmin'''

    PRINT @tmpstr

    END

    IF @xstatus &128 = 128 -- setupadmin

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''setupadmin'''

    PRINT @tmpstr

    END

    IF @xstatus &256 = 256 --processadmin

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''processadmin'''

    PRINT @tmpstr

    END

    IF @xstatus &512 = 512 -- diskadmin

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''diskadmin'''

    PRINT @tmpstr

    END

    IF @xstatus &1024 = 1024 -- dbcreator

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''dbcreator'''

    PRINT @tmpstr

    END

    IF @xstatus &4096 = 4096 -- bulkadmin

    BEGIN

    SET @tmpstr = 'exec master.dbo.sp_addsrvrolemember @loginame=''' + @name + ''', @rolename=''bulkadmin'''

    PRINT @tmpstr

    END

    FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd, @dfltdb

    END

    END

    CLOSE login_curs

    DEALLOCATE login_curs

    RETURN 0

    GO

    exec sp_help_revlogin_2000_to_2005 @login_name=NULL, @include_db=1, @include_role=1

    GO

Viewing 15 posts - 16 through 30 (of 39 total)

You must be logged in to reply to this topic. Login to reply