0

I have to migrate complex SQL query need to convert in Postgres.

Complex SQL query : More than 4 table Join , lots of filter , Aggregate functions, CASE when then etc.

For Ex: Sample input

    Select  
    ROW_NUMBER() OVER (ORDER BY getdate()) AS ID, 
    GETDATE() as time,
    arc.Customer as Customer,
    GroupBy4KPI,
    arc.MasterAccount,
    arc.CustomerClass,
   from tablename_1 arc left join  tablename_2 varc on arc.Customer = varc.Customer

Please suggest if we have any custom function or tool to accomplish conversion of DML statement from MSSQL to PSQL.

Fact

Such, 1600 Queries i have to parse. So, this job is repetitive one. i have to perform or parse MSSQL queries on daily basis.

Any help on it would be much appreciated ?

NEO
  • 389
  • 8
  • 31
  • 2
    I doubt you are going to find a magic wand to make this conversion anything other than a manual process. And I would be wary of any such tool not creating horrific queries anyway. You are likely going to have to manually convert every query. This is also quite likely to be closed as being off topic for looking for a tool recommendation. I don't envy you on this project. It sounds like a painful one. – Sean Lange Jun 30 '17 at 15:35
  • Got it. Still, Any tips while handling this conversion as manual process. – NEO Jun 30 '17 at 15:40
  • 2
    Maybe run a postgres `EXPLAIN` to validate the queries? At least that way you can know if you need to change the query or not before you dive into it. – Jacob H Jun 30 '17 at 15:41
  • Please don't add the `postgresql` tag if you are using Greeplum. They are sufficiently different. The query shown will work just fine if you replace `getdate()` with `now()` or the SQL standard's `current_date` –  Jun 30 '17 at 15:52
  • @a_horse_with_no_name is correct on both points. Just change getdate() to now() and don't tag Greenplum posts with PostgreSQL. – Jon Roberts Jun 30 '17 at 15:58

0 Answers0