Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2007

    Unanswered: MS SQL to PostgreSQL Conversion


    I am in the process of converting a database from MS SQL Server to PostgreSQL and I am having a few problems getting the data in to postgreSQL.

    Basically i've read up on it and got a few examples of using the COPY command, but I'm sure I'm missing something because no matter what syntax I use I am still unable to insert the data from a CSV file from SQL Server into PostgreSQL.

    What I would really appreciate is if someone has a decent link to one, with example or if someone can give me a quick example here of how to do it. For example, if I want to get the data from a file called data.csv into a table called table1 then I've been trying :

    COPY table1 FROM 'c:/data.csv'
    The error varies each time, but it's not actually giving an error message as such, and I dont know whether it's because I'm not specifying the correct paramaters or whether I need to not have a table in the database already, or whether I need row headers in the CSV file or something?

    Any help you can give would be great,

  2. #2
    Join Date
    Jun 2004
    Arizona, USA
    Did you review Ethan Townsend's document Conversion of Microsoft SQL/ASP applications to PostgreSQL at PostgreSQL.Org ?

    He suggests using SQL Server's "Export Data" uility from Enterprise Manager.

    In another conversion article, Ryan Bonham recommends using DTS.

    Now, in the oldest of the three conversion articles from SQL Server to PostgreSQL, Ian Harding discusses using COPY to import the data. He DOES mention that SQL Server uses lf and cr as the end of line (newline) terminator, whereas postgreSQL uses lf character only.
    Last edited by loquin; 03-20-07 at 16:12.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

  3. #3
    Join Date
    Feb 2007


    Hi Loquin,

    Thanks for your reply and the links - I'll have a look at those and I'm sure one of them is bound to work - Plenty of reading anyway.

    Thanks again,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts