Introduction
The ZappySys PostgreSQL ExecuteSQL Task is an SSIS task that runs SQL statements against a PostgreSQL database. You do not need to install an extra ODBC or OLE DB driver. This article shows how to create a PostgreSQL connection and run a script to drop and recreate a table.
Prerequisites
- Download and install the ZappySys SSIS PowerPack.
- Have access to a PostgreSQL database.
Steps
-
Open Visual Studio and create a new Integration Services project, or open an existing package.
-
Drag the ZS PostgreSQL ExecuteSQL Task from the SSIS Toolbox onto the Control Flow.
-
Double-click the task to edit it.
-
Click New Connection to create a PostgreSQL connection. If you already have one, select it and skip to step 7.
-
Enter the Host name, User name, Password, and Database name. Leave the other properties at their defaults unless your server needs them, for example, a port other than
5432. -
Click Test Connection. If the test succeeds, click OK to save the connection.
-
Keep DirectValue as the SQL source type and enter the following statements. They drop the table
pg_equipmentif it exists and create it again. You can change the table and column names.
DROP TABLE IF EXISTS pg_equipment;
CREATE TABLE pg_equipment (
equip_id serial PRIMARY KEY,
type varchar(50) NOT NULL,
color varchar(25) NOT NULL,
location varchar(25) CHECK (location IN ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),
install_date date
);
-
Click OK to save the task settings.
-
Right-click the task and select Execute Task. The task turns green when the statements are complete.
-
Check the new table in pgAdmin or
psql, for example, withSELECT * FROM pg_equipment;.
Notes
- Test
DROPstatements on a development database first. - Separate multiple statements with a semicolon (
;), as in the example above. - PostgreSQL converts unquoted names to lowercase:
CREATE TABLE PG_Equipmentcreatespg_equipment. - If Test Connection times out, check the host name and port, and make sure the firewall allows outbound traffic from the SSIS server.
- If the task fails with
permission denied, the user needs CREATE privileges on the schema.
Video tutorial
Conclusion
The PostgreSQL ExecuteSQL Task runs SQL against PostgreSQL from SSIS without installing an extra driver. Create a PostgreSQL connection, enter your SQL statements, and run the task as part of your package.
Still need help?
If you need assistance using the PostgreSQL ExecuteSQL Task, please get in touch with our support team:
- Live Chat: Open the chat widget (bottom right of this page)
- Email: support@zappysys.com
- Support Center: Support | ZappySys




