Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. export to text file + SQL

export to text file + SQL

Scheduled Pinned Locked Moved Database
databasetutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jojoba2011
    wrote on last edited by
    #1

    How to export query results into text file ?

    V S 2 Replies Last reply
    0
    • J jojoba2011

      How to export query results into text file ?

      V Offline
      V Offline
      vvashishta
      wrote on last edited by
      #2

      For That You Have To Activate Few Services In SQL Server :: Execute This Command Set; EXEC master.dbo.sp_configure 'show advanced options', 1 RECONFIGURE EXEC master.dbo.sp_configure 'xp_cmdshell', 1 RECONFIGURE Now To Get Output of any SQL query in a text file write this query: EXEC xp_cmdshell 'bcp "YOUR QUERY HERE" queryout "Location Of TextFile Here" -T -c -t,'

      - Happy Coding - Vishal Vashishta

      1 Reply Last reply
      0
      • J jojoba2011

        How to export query results into text file ?

        S Offline
        S Offline
        Sandeep Mewara
        wrote on last edited by
        #3

        Have a look at these: SQLServer: Simple way to export SQL Server data to Text Files[^] SQLServer: Save Select query result into Textfile[^] MySQL: Save MySQL query results into a text or CSV file[^]

        Sandeep Mewara [My last tip/trick]: Server side Delimiters in ASP.NET[^]

        J 1 Reply Last reply
        0
        • S Sandeep Mewara

          Have a look at these: SQLServer: Simple way to export SQL Server data to Text Files[^] SQLServer: Save Select query result into Textfile[^] MySQL: Save MySQL query results into a text or CSV file[^]

          Sandeep Mewara [My last tip/trick]: Server side Delimiters in ASP.NET[^]

          J Offline
          J Offline
          jojoba2011
          wrote on last edited by
          #4

          Thanks For Reply . I have use this code :

          EXEC master.dbo.sp_configure 'show advanced options', 1
          RECONFIGURE
          EXEC master.dbo.sp_configure 'xp_cmdshell', 1
          RECONFIGURE

          EXEC xp_cmdshell 'bcp "SELECT * FROM Silver.tblGroups" queryout "C:\bcptest2.txt" -T -S ALIJOONASUS\wintapsqlexpress -c -t,'

          But i wanna to have UTF-8 text file. and Secondly : How to have Columns Name also

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups