Problem Assumption:
I have a table in SQL Server, with the structure as follows;
Column 1: Id | INT | NOT NULL | Auto-Identity
Column 2: Name | VARCHAR(20) | NOT NULL
Column 3: Number | SMALLINT | NOT NULL
Solution Scenario:
What I want is that whenever some value is entered in a column, then it should be verified or validated against certain checks, at database level itself?
Example:
The column 3, Number” should only allow:
- numeric values
- with length 10
- and value should start with the digit 4
Could anyone please suggest the best way to implement this at database level?
I think your
numbercolumn should be fixed-width text e.g.