SQL Server Fix Orphaned User

When cloning databases in SQL Server from one server to another, you can run into the problem where the userid that is associated with the database is not valid in the security of the database engine that is hosting the new database.

An easy fix to this problem is to run the following statement:

EXEC sp_change_users_login ‘Auto_Fix’, ‘user

You can list all the users that are orphaned by running the following statement:

EXEC sp_change_users_login ‘Report’

Renaming Tables (Dealing with Duplicates)

Sometimes it is helpful to be able to rename a table in PeopleSoft. I find when dealing with duplicates in tables during upgrades, you can rename a table to a temporary table and then re-create the table in question and then simply do an insert into the new table from the temporary table using a select distinct statement.

SQL SERVER:
sp_rename ‘TABLENAME’, ‘NEWTABLENAME’

ORACLE:
alter table tablename rename to newtablename