Updated for cross database scripting.