• Aatish Patel (12/5/2013)


    I copied database from Prod to Dev instance. Whe the database was restored I ran

    -----See if there are any orphan users:

    EXEC sp_change_users_login 'Report'

    The output was :

    finq_sql 0xB058747F1E577148862C570381789901

    linkserver 0xE040BAD5EEE23049B759C8D750F6C82E

    NOTE : These 2 users are SQL users only and I not have password for them. They are there in Prod but not in Dev. SO How do i crate those users in Dev from Prod. I did script the user from Prod but gives me error that 'it does not meet the minimum password requirement'

    Can someone please tell me how to create user at instance level and map it to database in Dev?

    This script will generate the create login command retaining the password and SID. execute the script itself against the Prod server and then execute the output against the dev server

    SELECT'CREATE LOGIN ' + name + ' WITH PASSWORD = ' +

    sys.fn_varbintohexstr(password_hash) +

    ' HASHED, SID = ' + sys.fn_varbintohexstr(sid) +

    ', DEFAULT_DATABASE = ' + QUOTENAME(default_database_name) +

    ', DEFAULT_LANGUAGE = ' + default_language_name +

    ', CHECK_EXPIRATION = ' +

    CASE

    WHEN is_expiration_checked = 0 THEN 'OFF'

    ELSE 'ON'

    END +

    ', CHECK_POLICY = ' +

    CASE

    WHEN is_policy_checked = 0 THEN 'OFF'

    ELSE 'ON'

    END

    FROM master.sys.sql_logins

    WHERE name = 'yoursqllogin'

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

    "Ya can't make an omelette without breaking just a few eggs" 😉