Here is a really simple solutions to create and unsigned int on ms sql server. The following has been tested on sql server 2008. Unfortunately there is no native support for an unsigned int but we can force the functionality with using a big int and creating a set of rules based on a custom type. If we really still wanted to create an unsigned int we could of course use a .net clr class and build our own type. But that seems like overkill.
CREATE TYPE dbo.uint FROM bigint GO CREATE RULE uint_range AS @i >= 0 AND @i <= 4294967295 GO EXEC sp_bindrule 'uint_range', 'uint' GO
These sorts of rules are also useful for creating any custom type. eg phone number or such as well. The major difference is the rule is on the type not on the table constraint so they can be changed in all table's where they are being used at the same time.
Did You find this page useful?
Thanks for the feeback. Please consider sharing with others.