postgresql - Error in using postgres COPY in windows batch file -


this working perfectly. columns in table1 exported .csv file.

( echo \copy table1 '%home%\net\csv_output.csv' delimiter ',' csv header; ) | "c:\program files\postgresql\9.3\bin\psql.exe" -h %db_host% -p 5432 -u %db_user% -d %db_name% 

but wanted export selected columns .csv file have tried far not work.

i have tried using select returns error says "to unexpected @ time"

echo \copy (select red_foo table1) '%home%\net\csv_output.csv' delimiter ',' csv header; 

i have tried remove parentheses returns error says

"\copy: parse error @ "red_foo""

what should correct way implementation? suggestions , ideas highly appreciated.

using suggestion of @a_horse_with_no_name in comments, have exported .csv file selected columns.

a separate sql script contains \copy statement used on psql command on windows batch script , works charm.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -