If you want to add data from a database into a spooled file via SQL, then you should consider these options:
1.Enrich spooled file from database workflow component inside your workflow.
2.You can also consider to use the ng:databaseLookup function for a spooled file within a transformation. Here you can e.g. transform a spooled file into another spooled file and at the same time add extra data into a new attribute
3.You can also add the extra SQL data into a spooled file line.
4.You can even add data into a new, hidden attribute in the spooled file.
5.After running this in the workflow you can refer to the extra data both in the workflow and in the designer and even save a copy of the changed contents with the To filesystem component.