How To Save T-SQL Query Results To File Without Using SSIS

  • If I wanted to implement something in SQL Server 2005 that would take the results from a query, specifcially a view, and save them to a plain old ASCII text file with the file extension of 'prn', and do it

    a) On a recurring schedule

    b) without Using SSIS

    How would I do it?

    I have a query in place that will produce the results; a single column that is the concatenation of several pieces of varchar & char data. I'd like to send the results to a prn file and on a schedule if possiobel without usiing SSIS. Any suggestions?

    Thanks

    Kindest Regards,

    Just say No to Facebook!
  • a) On a recurring schedule

    Using Google "sql server scheduled job"

    You should get About 285,000 results (0.16 seconds)

    b) without Using SSIS

    Use Google "SQL Server Bulk Export"

    You should get About 220,000 results (0.35 seconds) .

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • bitbucket-25253 (6/6/2011)


    a) On a recurring schedule

    Using Google "sql server scheduled job"

    You should get About 285,000 results (0.16 seconds)

    b) without Using SSIS

    Use Google "SQL Server Bulk Export"

    You should get About 220,000 results (0.35 seconds) .

    Thanks for the recomendation of looing at Bulk Exporting. I've never used BCP before (we've always used a third party tool for import & export in bulk) and so it wasn't as obvious to me that it would be a possible solution. I was fully expecting to get 'You Gotta Use SSIS' replies only.

    Luckily I managed to find a workable sample script to go from but searching Google, while returning many, many rows, was definately not quick. It took some time to find a simple, sample piece of T-SQL that could be dropped inside as SQL Job.

    Thanks

    Kindest Regards,

    Just say No to Facebook!
  • SqlCmd is an alternative to BCP that offers a bit more control if you need to output column headers.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • does your script cater for saving in xls format as i have a similar problem?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply