pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Moving data from SQL Server to Postgres via VFP ODBC Driver
4+ messages / 3 participants
[nested] [flat]

* Moving data from SQL Server to Postgres via VFP ODBC Driver
@ 2010-08-09 17:13  Calvin <calvinsmith266@hotmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Calvin @ 2010-08-09 17:13 UTC (permalink / raw)
  To: pgsql-odbc

I am attempting to move data from a SQL Server 2008 database to Postgres v8.4. I
am using Visual Fox Pro as an intermediate step in this process. I open a
connection to the SQL tables using the ODBC driver and at the same time open a
connect to the PostGres table using PostgresSQL30. The reason I am doing it this
way is I cannot seem to overcome issues concerning bit fields in SQL Server and
Booleans in Postgres. Using VFP I can do a quick and dirty conversion. However,
the problem is that when I look at the data in Postgres it converted
successfully with the exception of varying character fields which have been
padded to their maximum length. My insert statement is in the form :

Insert into PostgresTableName Values(m.field1, trim(m.field2....)

The m. systax is because I am using memory variables in VFP. The data contained
in the m.fields has all be trimmed if it is character type. 

Is there any way to keep varying character fields from being padded out to their
maximum length.

Thanks!




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Moving data from SQL Server to Postgres via VFP ODBC Driver
@ 2010-08-09 17:59  Richard Broersma <richard.broersma@gmail.com>
  parent: Calvin <calvinsmith266@hotmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Richard Broersma @ 2010-08-09 17:59 UTC (permalink / raw)
  To: Calvin <calvinsmith266@hotmail.com>; +Cc: pgsql-odbc

On Mon, Aug 9, 2010 at 10:13 AM, Calvin <calvinsmith266@hotmail.com> wrote:
> I am attempting to move data from a SQL Server 2008 database to Postgres v8.4. I
> am using Visual Fox Pro as an intermediate step in this process. I open a
> connection to the SQL tables using the ODBC driver and at the same time open a
> connect to the PostGres table using PostgresSQL30. The reason I am doing it this
> way is I cannot seem to overcome issues concerning bit fields in SQL Server and
> Booleans in Postgres. Using VFP I can do a quick and dirty conversion. However,
> the problem is that when I look at the data in Postgres it converted
> successfully with the exception of varying character fields which have been
> padded to their maximum length. My insert statement is in the form :

It would seem that the string padding is taking place on the
SQL-Server side.  Is there anyway to verify if it is treating the
varchar type as char in its odbc driver?

If you need to you can put the trimming operation in before insert
trigger functions on these columns. But I expect this solution is not
optimal.


-- 
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Moving data from SQL Server to Postgres via VFP ODBC Driver
@ 2010-08-09 18:50  Richard Broersma <richard.broersma@gmail.com>
  parent: Richard Broersma <richard.broersma@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Richard Broersma @ 2010-08-09 18:50 UTC (permalink / raw)
  To: calvin smith <calvinsmith266@hotmail.com>; +Cc: pgsql-odbc

On Mon, Aug 9, 2010 at 11:31 AM, calvin smith
<calvinsmith266@hotmail.com> wrote:

> Thank you for your reply. Actually I am dumping the data from SQLServer into
> Visual FoxPro memory variables on a record by record basisĀ  and then
> checking the datatype for each memory variable.. If the data type is VFP
> character I am trimming the value so that I KNOW that what is going into my
> Insert statement is trimmed data.

I haven't used VFP.  Is it an ETL tool?

Another ETL tool to consider (its open source) that is JDBC based can
be found here:
http://sourceforge.net/projects/pentaho/files/Data%20Integration/4.0.0-stable/

Also, I don't know if you seen these migration resources:
http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#Microsoft_SQL_Server

Hopefully there is something useful there.

Also don't forget to reply-all so that the mailing list is included so
that others can reply.

-- 
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Moving data from SQL Server to Postgres via VFP ODBC Driver
@ 2010-08-09 19:03  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Calvin <calvinsmith266@hotmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Tom Lane @ 2010-08-09 19:03 UTC (permalink / raw)
  To: Calvin <calvinsmith266@hotmail.com>; +Cc: pgsql-odbc

Calvin <calvinsmith266@hotmail.com> writes:
> Is there any way to keep varying character fields from being padded out to their
> maximum length.

I suspect that your "varying" fields are in fact declared as just
CHAR(n).  Use VARCHAR(n), or if there isn't a particularly good reason
to have a specific length limit, use TEXT.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2010-08-09 19:03 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-08-09 17:13 Moving data from SQL Server to Postgres via VFP ODBC Driver Calvin <calvinsmith266@hotmail.com>
2010-08-09 17:59 ` Richard Broersma <richard.broersma@gmail.com>
2010-08-09 18:50   ` Richard Broersma <richard.broersma@gmail.com>
2010-08-09 19:03 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox