473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Copy command and import - MS SQL Server to Postgres

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 ???


Thanks !
Goutam

Confidentiality Notice
The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you havereceived this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited.
Nov 23 '05 #1
4 12498
On Fri, 5 Nov 2004 16:31:21 -0500, Goutam Paruchuri
<gp********@oneil.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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
On Fri, 2004-11-05 at 16:48, Allen Landsidel wrote:
On Fri, 5 Nov 2004 16:31:21 -0500, Goutam Paruchuri
<gp********@oneil.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


What about the ".000" on the end? I am not able to enter that format in
a timestamp field in 7.4.5, it is invalid.

--
Robert
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #3
Robert Fitzpatrick <ro****@webtent.com> writes:
My input file has the timestamp value like
2004-09-30 11:31:00.000
What about the ".000" on the end? I am not able to enter that format in
a timestamp field in 7.4.5, it is invalid.


Nonsense.

regression=# select '2004-09-30 11:31:00.000'::timestamp;
timestamp
---------------------
2004-09-30 11:31:00
(1 row)

regression=# select '2004-09-30 11:31:00.001'::timestamp;
timestamp
-------------------------
2004-09-30 11:31:00.001
(1 row)

regression=# select '2004-09-30 11:31:00.000'::timestamptz;
timestamptz
------------------------
2004-09-30 11:31:00-04
(1 row)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #4
I know this doesn't answer your question, but have you considered doing it with DTS instead of BCP?
I used it recently to migrate an Access database to PostGreSQL and it worked great. One of the big advantages is the ability to transform the data as it is being converted.
It is also built in to MSSQL Server. I have used it numerous times for data transformations within SQL Server and have always enjoyed working with it.
""Goutam Paruchuri"" <gp********@oneil.com> wrote in message news:B2************************************@DAYTON EX.oneilinc.net...
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 ???
Thanks !
Goutam

Confidentiality Notice
The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited.

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: cbb | last post by:
I'm using ver. 7.4.6.1 from a generic install of Fedora Core 3. I always get "permission denied" error when using the COPY command to load to a table from a text file. I'm logged on to the db as...
9
by: Sarah | last post by:
Hi! I have perhaps a strange question... I have a javascript that activates on a right click and shows the user a little menu of links. However, by doing so, it disables the users ability to...
2
by: Don Isgitt | last post by:
Hi, I am recreating a database and its applications onto a new server and new software; old version of pg was 7.2.4 and new version is gds2=# select version(); version ...
2
by: J M | last post by:
How do I run following from csharp from "server"? copy file.txt \\server\printer1 Also how can I submit a text file print job to local print queue "printer1"? Assuming I run copy command from...
1
by: edwilli | last post by:
I'm using the file system object in VB6 to copy files to a print queue. The copy command has been working great for Windows Server 2000. But when we upgraded to Server 2003 it hangs the...
1
by: Bob Powell | last post by:
To whom it may concern: Does anyone know if it is possible to make the COPY command in postgres verbose. It would be very helpful if an error would generate when something goes wrong with a...
4
by: Jon Asher | last post by:
Hi, I'm trying to do a simple import of a comma delimited text file with COPY but it's returning an error. The file has been granted all permissions in Linux, so it's not clear to me what the...
0
by: Robert Fitzpatrick | last post by:
I have a PHP script that was having problems using the COPY command with files around 1500 lines in size. The script will build the copy data from incoming CSV file into a temp file, then start a...
3
priyan
by: priyan | last post by:
hai everybody, I need to copy data from a text file to a table i used copy command like this copy city from 'e\ccccc.txt' with delimiter as ',' it worked successfully. But now i...
1
by: sriathma | last post by:
How to Copy empty structure using Postgres. Sridharan
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.