Stuck process when using sed command

$BIN/sql.py "select * from reporting.V_AMSNB_OPT_PB_LOAD" | sed -n "2,$ p"  | sed "s/   /,/g" > $DATADIR/OPT_PB_LOAD_AMSNB.csv
if [ $? -ne 0 ]

The processes that get created from the above code gets stuck...as in the processes get created but then never completes. (or at least we assume it never completes as we have been killing the process after a couple of hours) We use this exact same code except with a different database view and there are no issues with that particular code. It executes and completes just fine. I have tried runnign the same select statement as above at the database level and there is no issue retrieving the data.

It would seem as though there may be something related to the data that may be causing the process to get stuck? Does anyone know what could cause this process to get stuck? :confused:

when you run this command, it gives the output immediately ?

$BIN/sql.py "select * from reporting.V_AMSNB_OPT_PB_LOAD"