i got excited when i read somewhere about the existence of computed columns in SQL Server. This is because i like using binary bitwise numbers to uniqely identify rows within my database.
So I tried creating a table and creating a fomula which calculates a unique binary mask fom the shippingID the IDDENTITY collum. This Saves no problem and i know the fomula works OK in VB. However when I inset data into this table 'Test1' i get some strange results. where Shppingid is 1 i get a shippingmaskid of 2 (when i would expect a 1) Where Shipping ID is 2 i get a mask of -1 when i would expect a 2?! etc..
CREATE TABLE Test1
{
ShippingID int IDENTITY NOT Null,
ShippingMaskID AS 2^([ShippingID] - 1),
ShippingDescription varChar(50) NULL
}
Any help appreciated. Is there a better way to do this?
thanks
-Gus
So I tried creating a table and creating a fomula which calculates a unique binary mask fom the shippingID the IDDENTITY collum. This Saves no problem and i know the fomula works OK in VB. However when I inset data into this table 'Test1' i get some strange results. where Shppingid is 1 i get a shippingmaskid of 2 (when i would expect a 1) Where Shipping ID is 2 i get a mask of -1 when i would expect a 2?! etc..
CREATE TABLE Test1
{
ShippingID int IDENTITY NOT Null,
ShippingMaskID AS 2^([ShippingID] - 1),
ShippingDescription varChar(50) NULL
}
Any help appreciated. Is there a better way to do this?
thanks
-Gus