How can I create a plain-text flat file from SQL Server as
input to another application?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / skybeaver
Use the BCP utility
bcp out Database.dbo.TableName FileName.txt -T -c
| Is This Answer Correct ? | 0 Yes | 2 No |
Explain about builtinadministrator?
What are the new security features added in sql server 2012? : sql server security
What is query cost in sql server?
What are the differences between triggers and stored procedures?
Can you change the data type of a column in a table after the table has been created? If so, which command would you use?
How retrieve field names from the table in SQL through JAVA code?
What is the difference between varchar and nvarchar types?
What are the differences between stored procedure and functions in SQL Server 2000?
25 Answers College School Exams Tests, HCL, Infosys, TCS,
Other than truncate statement, which other command can by-pass the trigger on the tables?
When would you prefer to have a minimum number of indexes?
How to create a scrollable cursor with the scroll option?
How many cores do I need for sql server 2016?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)