bitwise identity for static lookup table???

  • This design limits the number of possible values to:

    • 31 if the Int field is used.
    • 63 if the BigInt field is used.

    If you are happy with that then why not prepopulate the table.  Issues are only 2n-1

  • Cheers...

    But the size of the field isn't an issue the real question is creating the identity with LastIdentity2.

    Do you have any ideas?

  • DECLARE @tbl TABLE(Id Int , Issue CHAR(8))

    DECLARE @byLoop TinyInt

    SET @byLoop=1

    WHILE @byLoop<32

     BEGIN

      INSERT @tbl(Id , Issue)

      SELECT POWER(2,@byLoop-1),'Issue ' + CAST(@byLoop AS VARCHAR(2))

      SET @byLoop=@byLoop+1

     END

    SELECT * from @tbl

  • Note POWER will give an arithmetic error if you exceed 31 issues because POWER can only return a 32 bit integer.

  • Thanks!

    I think i just need to plug that into a udf and call it from the item default.

    Sorry it the first time i've posted a question do i have to give you points???

    Once again thanks a lot...

  • No there's no point involved in this forum... except maybe the number of postings we do and how well we performe in the Question of the day "contest".

Viewing 6 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply