you can populate fields in a File with Attributes from a SQL statement.
EXEC SQL
SELECT SSN, NAME
INTO :O-SSN, :O-NAME
FROM MYTABLE
END-EXEC
This is a generic example from A Guide to SQL, by Philip J Pratt, Third Edition. The exact from of the SQL may differ. The fields in the file are in the into section. I am sure someone has a real example in a given SQL server language if you want something specific. My example doesnt show how each record is written. There are products that can make files also like EZTRIEVE and Decision Analyzer. If you do not like my post feel free to point out your opinion or my errors.