No.
This is not a get-code-for-free site.
a) You have not specified what kind of "flat file" you want (delimiter: tab/comma/semcolon? Text qualifier? encoding ASCII, UTF-8 or Unicode?)
b) You don't actually need code for that. SQL Server provides an export/import utility, also you can output queries to files.
c) If you need code for that, then why? What do you want to achieve? Are you sure "flat file" is the correct format?
d) What have you tried so far? Code snippets? YOu can find a lot using Google alone.
“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.