i'm trying write script copies data crosstab query .csv file in postgres 8.4. able run command in psql command line when put command in file , run using -f option, syntax error. here's example of i'm looking @ (from this great answer): create temp table t ( section text ,status text ,ct integer ); insert t values ('a', 'active', 1), ('a', 'inactive', 2) ,('b', 'active', 4), ('b', 'inactive', 5) , ('c', 'inactive', 7); \copy ( select * crosstab( 'select section, status, ct t order 1,2' ,$$values ('active'::text), ('inactive')$$) ct ("section" text, "active" int, "inactive" int) ) 'test.csv' header csv i run , following syntax error: $ psql [system specific] -f copy_test.sql create table insert 0 5 psql:copy_test.sql:12: \copy: parse error @ end of li...