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. Extra Spaces when Generating a text file using OSQL

Extra Spaces when Generating a text file using OSQL

Scheduled Pinned Locked Moved Database
databasequestion
3 Posts 2 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.
  • D Offline
    D Offline
    Daredeviljpr
    wrote on last edited by
    #1

    I am using OSQL to generate a text file. The query used to fetch records for the text file returns a variable length record. The text file generated contains extra spaces at the end of the record. The total length of the record including spaces is equal to the databse table field length. Executing the query in Query Analyzer does not give any extra space. Is there any way where I get the record without any extra space in the text file?

    E 1 Reply Last reply
    0
    • D Daredeviljpr

      I am using OSQL to generate a text file. The query used to fetch records for the text file returns a variable length record. The text file generated contains extra spaces at the end of the record. The total length of the record including spaces is equal to the databse table field length. Executing the query in Query Analyzer does not give any extra space. Is there any way where I get the record without any extra space in the text file?

      E Offline
      E Offline
      Edbert P
      wrote on last edited by
      #2

      Daredeviljpr wrote: The total length of the record including spaces is equal to the databse table field length Check the datatype of your column. If you use char or nchar, your text will be padded with extra space. If for some reason you can't change the column's data type, just trim the extra space at the end. HTH. Ed

      D 1 Reply Last reply
      0
      • E Edbert P

        Daredeviljpr wrote: The total length of the record including spaces is equal to the databse table field length Check the datatype of your column. If you use char or nchar, your text will be padded with extra space. If for some reason you can't change the column's data type, just trim the extra space at the end. HTH. Ed

        D Offline
        D Offline
        Daredeviljpr
        wrote on last edited by
        #3

        I am using varchar as the datatype. I also tried using ltrim, rtrim but of no use. when we run the query in Query Analyzer no spaces are shown but when the text file is generated spaces are padded to the right. I am concatenating the field values to make one column and then generate a text file. Is there any way to remove those extra spaces...

        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