How to upload Netezza NZSQL and NZLOAD output to a file.

Posted: October 2, 2014 in Netezza


Can I export the SQL query results from Netezza? 




Lets see how to do this

nzsql -u USER001 -pw pass1 -db PGBDB201  -host myhost.com -c “SELECT * FROM COMPLE.PROD_DIM” > /infa001/Src/PROD.txt

the out put of the query “SELECT * FROM COMPLE.PROD_DIM” will be loaded to the file PROD.txt

Is the above query fails with any error, then that error will be captured in the file PROD.txt

For Auditing or for error capturing the above method is very use full (when you don’t have access to bad file or log file).

In the above example instead of using Query we can pass a script file which will have a set of query’s.

EX:-  open unix env

$ touch my_script

$ select * from product_dim; >> my_script

$ Select * from customer_dim; >> my_script

$ more my_script

select * from product_dim;
Select * from customer_dim;

and call my_script in NZSQL as follows 

nzsql -u USER001 -pw pass1 -db PGBDB201  -host myhost.com -f $QUER_PATH/my_script  > /infa001/Src/PROD.txt

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s