473,699 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\\m cfa\\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 12510
On Fri, 5 Nov 2004 16:31:21 -0500, Goutam Paruchuri
<gp********@one il.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\\m cfa\\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********@one il.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\\m cfa\\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*******@postg resql.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********@one il.com> wrote in message news:B2******** *************** *************@D AYTONEX.oneilin c.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\\m cfa\\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
2107
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 Postgres, have file permissions set to RW-R--R--, and it is located in /tmp (also tried putting it in the Postgres home directory). I am able to use the insert command successfully on the same table, so it's not a db permission problem. Any...
9
3029
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 use the Copy Command when doing a normal right click. I know that in some cases this would be good for someone who wants to make it harder to copy pictures from their site... but in this case I WANT people to be able to copy the pictures....
2
9733
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
4115
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 server. TIA!
1
1425
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 application. Any ideas. Dan
1
2846
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 COPY. In the case of an extraneous comma or quote, it would identify the offending record. Thanks Bob Powell
4
7035
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 problem is. Version 7.41 is installed... see below for details: A comma delimited text file has been placed in a local directory with permissions set to allow any user to read or write to it: /root/Desktop/server_transfer/WorldPoints_v2.txt'
0
2757
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 COPY command and loop through the copy data using pg_put_line to insert and then pg_end_copy after posting the last line as '\.'. Worked well under that 1500 line area. What I found was if I issue a pg_connection_busy($dbh) before the...
3
12179
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 need to copy a data from a text file which is in my system to the database in server..
1
1311
by: sriathma | last post by:
How to Copy empty structure using Postgres. Sridharan
0
8706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8633
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9055
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8947
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7787
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.