How can I create a plain-text flat file from SQL Server as
input to another application?

Answer Posted / guest

A. One of the purposes of Extensible Markup Language (XML)
is to solve challenges like this, but until all
applications become XML-enabled, consider using our faithful
standby, the bulk copy program (bcp) utility.
This utility can do more than just dump a table; bcp also
can take its input from a view instead of from a table.
After you specify a view as the input source, you can limit
the output to a subset of columns or to a subset of rows by
selecting appropriate filtering (WHERE and HAVING) clauses.

More important, by using a view, you can export data from
multiple joined tables. The only thing you cannot do is
specify the sequence in which the rows are written to the
flat file, because a view does not let you include an ORDER
BY clause in it unless you also use the TOP keyword.

If you want to generate the data in a particular sequence or
if you cannot predict the content of the data you want to
export, be aware that in addition to a view, bcp also
supports using an actual query. The only "gotcha" about
using a query instead of a table or view is that you must
specify queryout in place of out in the bcp command line.

For example, you can use bcp to generate from the pubs
database a list of authors who reside in California by
writing the following code:

bcp "SELECT * FROM pubs..authors WHERE state = 'CA'"
queryout c:\CAauthors.txt -c -T -S

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does view occupy space?

509


What is transaction server distributed transaction?

553


What is the difference between cartesian product and cross join?

478


Why are views required in the sql server or in any other database?

533


Can we use custom code in ssrs?

579






What is plan freezing?

580


Why is normalisation important?

494


Can you name a few encryption mechanisms in sql server?

536


Hi, I Created 3 Tables Person(PersID[prkey],Name,Email,Password), Project(ProjName,ProjID[prkey],ProjLeader,ProjManager) & ProjectInvolvement(EntryDate,ProjID[frkey],PersID[frkey],ProjDuration). For this how can i INSERT,UPDATE & DELETE Through PROCEDURE? Please Post the Answer for me. Desai.

1418


tell me the disaster recovery plan

2019


Explain indexing and what are the advantages of it?

520


Do you know what are the ways available in sql server to execute sql statements?

536


What is conditional split?

537


what is the difference in login security modes between v6.5 and 7.0? : Sql server database administration

643


What is database white box testing?

669