Initial Revision with enhancements for mssql to postgresql