The main (and rather critical) flaw is that it seems that the link you provide does not actually do what you think.
It just makes a new integer type that can only be positive, it does not provide you any space saving that would otherwise result from using an unsigned field (which seems to be your main goal). that is, the maximum value of their unsignedSmallint will be the same as the maximum value for smallint , so you will spend these extra bits anyway (but especially since you cannot insert negative values).
That is, their unsignedInt will not allow values above 2 ^ 31-1.
I understand and understand that in 100 million rows, the savings from using int32 vs int64 in one column is about 380 MB. Perhaps the best way to do this is to process it to compensate for your stored value after reading it, ideally in the view and only ever read from that view, and then insert -2 ^ 31 to the value when pasting .. But then the problem is in that the parsing for int32 happens before the insert, so INSTEAD OF triggers won't work. (I don’t know how to make an INSTEAD OF trigger that accepts different types in terms of ownership of the table)
Instead, your only option in this regard is to use stored procedures for set values, you can either use the view or stored proc to return the value:
create table foo (fooA int) GO CREATE VIEW [bar] AS SELECT CAST(fooA AS BIGINT) + 2147483647 AS fooA FROM foo GO CREATE PROCEDURE set_foo @fooA bigint AS BEGIN SET NOCOUNT ON;
This can be tested using:
exec set_foo 123 exec set_foo 555 select * FROM bar select * FROM foo exec set_foo 0 exec set_foo 2147483648 exec set_foo 4147483648 select * FROM bar select * FROM foo
You will see that the values returned are unsigned, but the returned values are int64, not unsigned32, so your application will have to process them as if they were still int64.
If you have a case when you see a significant improvement from this (for example, almost every column in the table is twice as large as it should be otherwise), then the above effort may be justified, otherwise I will simply stay instead of bigint .