Search Postgresql Archives

Re: Importing directly from BCP files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16 November 2015 at 15:31, Tim Uckun <timuckun@xxxxxxxxx> wrote:
Does anybody have any documentation on what a BCP file from SQL server looks like? 

That appears to depend on the -f option

https://msdn.microsoft.com/en-nz/library/ms162802.aspx

There's more details on the format files here https://msdn.microsoft.com/en-nz/library/ms191516.aspx

Have you tried opening a file in a text editor to see what they look like?
 
I have a directory full of BCP files and I would like to import them into PG.  


The default format seems to be separating values with a tab character. 

The bulk import command in PostgreSQL is COPY, so you'll likely want to look at http://www.postgresql.org/docs/9.4/static/sql-copy.html 
Let's assume you have *.bcp files in the default format with values separated with tabs, you could open up psql and use a command something along the lines of:

copy <table name> from '<filename>' delimiter ' '; -- <- use a tab character between the quotes.

Of course, you'll need to create the table first with CREATE TABLE.
 
Has anybody done anything like this before?


I'd imagine that it's fairly common.

--
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux