I have a query in a(.sql) file "Provider.sql" . The query is ,
select
P.ID AS P_ID,
P.LASTNAME AS L_N,
P.FIRST_NAME AS F_N,
FROM
PROVIDER P
How do i export the output of this "Provider.sql" file to a '|' delimited text file?
P_ID|L_N|F_N 1|FRASER|SCOTT
I can export the output to a file manually from "PGADMIN III".
However I would like to automate this using PSQL.
What will be best approach to send the output of this .sql file to a text file with pipe delimiters?
Can you help me with an example?
\copywith hugely complex queries sometimes. You can always use a view, too. As for the output being "mangled" ... well, what output did you expect, and how was it different to what you got? Show some examples please. (Edit the question to add them, then comment here).