views:

54

answers:

1

I have a SQL Server 2005. I have created a linked server to PG SQL server.

It works great.

SELECT * 
FROM OpenQuery(POSTGRESQL_SERV,
               'SELECT comp_id,comp_name FROM company WHERE comp_type = 5')

I need to read all data from PG SQL and insert it into SQL Server.

How to create a while ? (also unique id`s)

Thx.

+2  A: 

Not sure if I understand your question entirely (while? unique id's?), but all you'd be doing would be an insert statement:

insert into MyTable ( comp_id, comp_name )
select comp_id, comp_name
from OpenQuery(POSTGRESQL_SERV,'SELECT comp_id,comp_name FROM company WHERE comp_type = 5')

As to creating unique ID's, you'd want to have an IDENTITY column on your destination table, which would create the ID's for you.

David T. Macknet