• We have a test server where we restore a database and adjust the name adding the date to identify the version.  Each time we do this we need to set the User from the database to the Server login.  This seemed like a good solution for us.  However running the code is giving me an error:
    Msg 102, Level 15, State 1, Line 28
    Incorrect syntax near '..sysusers su
    JOIN sys.server_principals sp ON sp.name = su.name
    WHERE issqluser = 1 AND
    (su.sid IS NOT NULL AND su.sid <> 0x0'.

    The code in question starts with:  FROM '+quotename(@DatabaseName)+'..sysusers su

    I am unsure where to go from here.  Suggestions?