hey I'm new in SQL server i was wondering if we can set range to int (when creating table) like we set range to char
testing char(5) not null
when i tried to use the same way to set range in int
testing int(5) not null
it will get error, so how to set range for int. if can't can you tell me why?
There is no INT(5) data type in sql server , but you can make use of CHECK constraints to put a limit/Range on values that can be inserted in that column.
Google to learn more about Check Constraint and you would do something like this.....
CREATE TABLE MyTable
(
Testing INT CHECK (testing > 100 AND testing <500)
, OtherCol INT
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With