Results 1 to 6 of 6

Thread: How to sent Query Result to a Text File

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2003
    Posts
    24

    How to sent Query Result to a Text File

    Dear Friends,

    How can i sent the results of a stored procedure to a Text File (Text Format) in SQL Server 2000


    thanx

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Through SQL Server, correct?

    Check out documentation for the osql utility in SQL Server help.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2003
    Posts
    24
    Thanks


    We can create a web page (text file with html tags) using sp_makewebtask procedure. But can i to execute through a user defined Stored procedure to create a text file without html tags ?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Like this:

    Code:
    declare @cmd varchar(1000)
    select @cmd = 'osql -U -P -S -Q"select * from tablename" -o"c:\mendhak.txt" -w500'

    I don't know if there are any stored procedures that let you do this, though. Just create the above proc, and execute it.

    exec sp_whatever @cmd

  5. #5
    Hyperactive Member sw_is_great's Avatar
    Join Date
    Nov 2003
    Posts
    330
    try using spool
    Regards

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2003
    Posts
    24
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width