Prev: Updating SQL Server from ASP TextArea
Next: MSSQL 2005, TSQL, Keywords and variables, Case sensitive or not?
From: mcolson on 8 Mar 2010 08:33 I am trying to create a stored procedure to write out to a text file. I would like it to write a line for each instance of a select statement. Any help? Write information Where field1 = String
From: Plamen Ratchev on 8 Mar 2010 09:51 You can use the BCP utility to output the SELECT statement data to a file: http://msdn.microsoft.com/en-us/library/aa174646(SQL.80).aspx Or look at SSIS which may be a better environment for the task: http://decipherinfosys.wordpress.com/2008/07/23/ssis-exporting-data-to-a-text-file-using-a-package/ -- Plamen Ratchev http://www.SQLStudio.com
From: Erland Sommarskog on 8 Mar 2010 18:03
mcolson (mcolson1590(a)gmail.com) writes: > I am trying to create a stored procedure to write out to a text file. > I would like it to write a line for each instance of a select > statement. Any help? > > Write information Where field1 = String In addition to Plamen's answer: normally you don't write to text files from SQL at all. You just return data to the client, and the client would write to the text file. BCP and SSIS that Plamen mentioned are examples of specialised such clients that are good of extracting lots of data. -- Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |