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. Select spaces and then the value???

Select spaces and then the value???

Scheduled Pinned Locked Moved Database
databasetutorialquestion
7 Posts 4 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.
  • S Offline
    S Offline
    Support123
    wrote on last edited by
    #1

    Hi, how (if at all) is it possible to do something like this... I want to select a column value from the database but i want to make sure that what i select, has a fixed length with spaces in the front of it if it is to short... example. ....Test1 .....Test .LongTest Each "." represents a space. (so the select statement should be something like: SELECT (BlankSpace for x amount... where x amount would be (in my example: 9) - Len(TestColumnValue) + TestColumnValue) ) This will ensure that the selected values are right aligned and all the same length... :doh: Is this possible and how if it is? I hope i explained what i need clearly... please let me know if you need more info. Thank you in advance.

    "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

    J J C 3 Replies Last reply
    0
    • S Support123

      Hi, how (if at all) is it possible to do something like this... I want to select a column value from the database but i want to make sure that what i select, has a fixed length with spaces in the front of it if it is to short... example. ....Test1 .....Test .LongTest Each "." represents a space. (so the select statement should be something like: SELECT (BlankSpace for x amount... where x amount would be (in my example: 9) - Len(TestColumnValue) + TestColumnValue) ) This will ensure that the selected values are right aligned and all the same length... :doh: Is this possible and how if it is? I hope i explained what i need clearly... please let me know if you need more info. Thank you in advance.

      "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

      J Offline
      J Offline
      joemonvarghese
      wrote on last edited by
      #2

      hi try this select right(space(20) + rtrim(FIELDNAME), 20) from TABLENAME Regards Joe

      S 1 Reply Last reply
      0
      • J joemonvarghese

        hi try this select right(space(20) + rtrim(FIELDNAME), 20) from TABLENAME Regards Joe

        S Offline
        S Offline
        Support123
        wrote on last edited by
        #3

        thank you... this looks promissing. I am playing around with this now. thank you for your time :-D

        "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

        1 Reply Last reply
        0
        • S Support123

          Hi, how (if at all) is it possible to do something like this... I want to select a column value from the database but i want to make sure that what i select, has a fixed length with spaces in the front of it if it is to short... example. ....Test1 .....Test .LongTest Each "." represents a space. (so the select statement should be something like: SELECT (BlankSpace for x amount... where x amount would be (in my example: 9) - Len(TestColumnValue) + TestColumnValue) ) This will ensure that the selected values are right aligned and all the same length... :doh: Is this possible and how if it is? I hope i explained what i need clearly... please let me know if you need more info. Thank you in advance.

          "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

          J Offline
          J Offline
          Joe 2
          wrote on last edited by
          #4

          I believe this was already dealt over here[^]

          Once you have mastered the ability to turn yourself invisible at will, and to deflect bullets with your hair, you will be ready to come back here to the lounge and post programming questions.Only at this point will you be able to dodge the fireballs that are going to come your way. - Pete O'Hanlon

          S 2 Replies Last reply
          0
          • J Joe 2

            I believe this was already dealt over here[^]

            Once you have mastered the ability to turn yourself invisible at will, and to deflect bullets with your hair, you will be ready to come back here to the lounge and post programming questions.Only at this point will you be able to dodge the fireballs that are going to come your way. - Pete O'Hanlon

            S Offline
            S Offline
            Support123
            wrote on last edited by
            #5

            i though i had it figured out too... But now with the space() function... i can get the result i am looking for without using variables. Thank you for your time

            "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

            1 Reply Last reply
            0
            • J Joe 2

              I believe this was already dealt over here[^]

              Once you have mastered the ability to turn yourself invisible at will, and to deflect bullets with your hair, you will be ready to come back here to the lounge and post programming questions.Only at this point will you be able to dodge the fireballs that are going to come your way. - Pete O'Hanlon

              S Offline
              S Offline
              Support123
              wrote on last edited by
              #6

              Sorry.... But what does the right( do (i used select right(space(20) + 'TEST', 25)? i tested the also with select left(space(20) + 'TEST', 25)... i did not notice a difference. What does the left or right do in this section?

              "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

              1 Reply Last reply
              0
              • S Support123

                Hi, how (if at all) is it possible to do something like this... I want to select a column value from the database but i want to make sure that what i select, has a fixed length with spaces in the front of it if it is to short... example. ....Test1 .....Test .LongTest Each "." represents a space. (so the select statement should be something like: SELECT (BlankSpace for x amount... where x amount would be (in my example: 9) - Len(TestColumnValue) + TestColumnValue) ) This will ensure that the selected values are right aligned and all the same length... :doh: Is this possible and how if it is? I hope i explained what i need clearly... please let me know if you need more info. Thank you in advance.

                "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

                C Offline
                C Offline
                Cristian Amarie
                wrote on last edited by
                #7

                select replicate('.', 9 - len(ltrim(rtrim(TestColumnValue)))) + ltrim(rtrim(TestColumnValue))
                from YourTable

                and this will left prefix with '.' character your field.

                Nuclear launch detected

                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