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. Unsigned data type.

Unsigned data type.

Scheduled Pinned Locked Moved Database
sql-servertutorialquestion
5 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.
  • E Offline
    E Offline
    Evgeni57
    wrote on last edited by
    #1

    Is there possibility to define unsigned type or convert already exist type, int for example, to unsigned int in MSSQL?

    B T S 3 Replies Last reply
    0
    • E Evgeni57

      Is there possibility to define unsigned type or convert already exist type, int for example, to unsigned int in MSSQL?

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Can you be more clear in your question?


      I Love T-SQL "Don't torture yourself,let the life to do it for you."

      E 1 Reply Last reply
      0
      • B Blue_Boy

        Can you be more clear in your question?


        I Love T-SQL "Don't torture yourself,let the life to do it for you."

        E Offline
        E Offline
        Evgeni57
        wrote on last edited by
        #3

        Sure. I have some unsigned short variable in C process and I need to load its values into database. The values of this variable may exceed 32K and I also don't want to use 4 bytes data valuse. Just like in C process - 2 bytes long.

        1 Reply Last reply
        0
        • E Evgeni57

          Is there possibility to define unsigned type or convert already exist type, int for example, to unsigned int in MSSQL?

          T Offline
          T Offline
          TheFM234
          wrote on last edited by
          #4

          There is no unsigned integer types in SQL Server, except for tinyint (0 - 255). You can use an user defined data type, but that will not make the size of the data smaller (which is what I'm assuming you want to do). You can also add a constraint to a column so the value is >= 0. As for saving space, no way to unsign an int.

          1 Reply Last reply
          0
          • E Evgeni57

            Is there possibility to define unsigned type or convert already exist type, int for example, to unsigned int in MSSQL?

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

            There are no unsigned integers in SQL Server, except for tinyint. So for bigger values define a INT or BIGINT data type ( as per your database demand ) and add a check contraint to accept only positive values. Like the below example. create table x_table(i int, j_Pos_value int constraint chk_j _cons Check (j_Pos_value>=0)) :-O

            "We can't solve problems by using the same kind of thinking we used when we created them"

            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