Re: Copy command and import - MS SQL Server to Postgres

From: Allen Landsidel <alandsidel(at)gmail(dot)com>
To: Goutam Paruchuri <gparuchuri(at)oneil(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Copy command and import - MS SQL Server to Postgres
Date: 2004-11-05 21:48:07
Message-ID: 88f1825a0411051348701ce02e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 5 Nov 2004 16:31:21 -0500, Goutam Paruchuri
<gparuchuri(at)oneil(dot)com> wrote:
>
> Iam trying to import data from ms-sql server to postgres. I export the data
> which has datetime columns in sql server using BCP. I use the following to
> import back into postgres.
>
> copy tablename from 'c:\\bcpdata\\mcfa\\tablename.txt' with delimiter as
> '\t'
>
> I get the following error !!
> invalid input syntax for type timestamp: ""
>
> My input file has the timestamp value like
>
> 2004-09-30 11:31:00.000
>
> Any clues ???

I recently did the same thing, I left DELIMITER alone since \t is the
default, but I did have to do "WITH NULL as ''" since some of the
datetimes in MSSQL were empty.

By default the copy will bomb out on NULL fields even if you don't
have a NOT NULL constraint on the column, for one reason or another.

I suppose "WITH NULL as NULL" would've worked just as well, in hindsight.

-Allen

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc G. Fournier 2004-11-05 22:00:49 Re: ALERT This mailing list may be voted into a newsgroup
Previous Message Goutam Paruchuri 2004-11-05 21:31:21 Copy command and import - MS SQL Server to Postgres