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. SQL Server Indexes [modified]

SQL Server Indexes [modified]

Scheduled Pinned Locked Moved Database
databasequestionsql-serversysadmin
12 Posts 5 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.
  • M mobius111001

    I have a table that has a PK index on a VARCHAR(10) field. I insert 'A'. Next I try to insert 'A '. The insert isn't allowed because of the index. How can I make it so that 'A ' is allowed to be inserted? Thank you in advance. EDIT: The first is just A. The second was A[space].

    modified on Monday, May 3, 2010 10:35 AM

    H Offline
    H Offline
    Henry Minute
    wrote on last edited by
    #3

    If you genuinely need to add a second 'A' (rather than just trying to find out what happens if you do), then the chances are that the design of your database is less than optimal.

    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

    1 Reply Last reply
    0
    • L Luc Pattyn

      yeah, primary keys are a nuissance; they have a habit of wanting to be unique. Remove the old 'A' before you insert a new 'A'. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      Prolific encyclopedia fixture proof-reader browser patron addict?
      We all depend on the beast below.


      M Offline
      M Offline
      mobius111001
      wrote on last edited by
      #4

      The first is just A. The second was A[space].

      1 Reply Last reply
      0
      • M mobius111001

        I have a table that has a PK index on a VARCHAR(10) field. I insert 'A'. Next I try to insert 'A '. The insert isn't allowed because of the index. How can I make it so that 'A ' is allowed to be inserted? Thank you in advance. EDIT: The first is just A. The second was A[space].

        modified on Monday, May 3, 2010 10:35 AM

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #5

        yes, there is an issue with trailing spaces; here[^] is one discussion of that topic. I would avoid such situations by trimming all text before it goes into the database, otherwise you'll get trouble sooner or later, as you can hardly see the spaces at all and they may cause your selections to behave inconsistently. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        Prolific encyclopedia fixture proof-reader browser patron addict?
        We all depend on the beast below.


        H C 2 Replies Last reply
        0
        • L Luc Pattyn

          yes, there is an issue with trailing spaces; here[^] is one discussion of that topic. I would avoid such situations by trimming all text before it goes into the database, otherwise you'll get trouble sooner or later, as you can hardly see the spaces at all and they may cause your selections to behave inconsistently. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Prolific encyclopedia fixture proof-reader browser patron addict?
          We all depend on the beast below.


          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #6

          Too slow Pattyn! :laugh: I still think it's in the wrong place. Shouldn't it be a reply to the OPs' second post?

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          L 1 Reply Last reply
          0
          • H Henry Minute

            Too slow Pattyn! :laugh: I still think it's in the wrong place. Shouldn't it be a reply to the OPs' second post?

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #7

            As he modified the OP, my answer stands; no need to demote it... :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            Prolific encyclopedia fixture proof-reader browser patron addict?
            We all depend on the beast below.


            H 1 Reply Last reply
            0
            • L Luc Pattyn

              As he modified the OP, my answer stands; no need to demote it... :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


              Prolific encyclopedia fixture proof-reader browser patron addict?
              We all depend on the beast below.


              H Offline
              H Offline
              Henry Minute
              wrote on last edited by
              #8

              OK. You get away with it.............this time. :-D

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              L 1 Reply Last reply
              0
              • H Henry Minute

                OK. You get away with it.............this time. :-D

                Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #9

                you're too kind. almost one of a. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                Prolific encyclopedia fixture proof-reader browser patron addict?
                We all depend on the beast below.


                1 Reply Last reply
                0
                • L Luc Pattyn

                  yes, there is an issue with trailing spaces; here[^] is one discussion of that topic. I would avoid such situations by trimming all text before it goes into the database, otherwise you'll get trouble sooner or later, as you can hardly see the spaces at all and they may cause your selections to behave inconsistently. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                  Prolific encyclopedia fixture proof-reader browser patron addict?
                  We all depend on the beast below.


                  C Offline
                  C Offline
                  Chris Meech
                  wrote on last edited by
                  #10

                  Luc Pattyn wrote:

                  as you can hardly see the spaces at all

                  I had a PHB asked me once if I could make the spaces blink. That way they could be seen. :rolleyes:

                  Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

                  L 1 Reply Last reply
                  0
                  • C Chris Meech

                    Luc Pattyn wrote:

                    as you can hardly see the spaces at all

                    I had a PHB asked me once if I could make the spaces blink. That way they could be seen. :rolleyes:

                    Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #11

                    Chris Meech wrote:

                    make the spaces blink.

                    That makes perfect sense: show all special characters the way MS Word does ("show/hide P"), however don't do it permanently, give the user the option to blink them. :)

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                    Prolific encyclopedia fixture proof-reader browser patron addict?
                    We all depend on the beast below.


                    1 Reply Last reply
                    0
                    • M mobius111001

                      I have a table that has a PK index on a VARCHAR(10) field. I insert 'A'. Next I try to insert 'A '. The insert isn't allowed because of the index. How can I make it so that 'A ' is allowed to be inserted? Thank you in advance. EDIT: The first is just A. The second was A[space].

                      modified on Monday, May 3, 2010 10:35 AM

                      P Online
                      P Online
                      PIEBALDconsult
                      wrote on last edited by
                      #12

                      VARCHARs don't make good primary keys anyway. X|

                      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