I am working on an assignment that requires that I add a constraint that makes sure that all values in a column are purely numerical. Im starting with
ALTER TABLE table_name
ADD CONSTRAINT ck_name CHECK (col_name LIKE 'pattern');
The problem is that the values can vary in length. I've been doing a lot of reading but i cant figure out a pattern that will limit it to numbers but still let it vary in length. I know in MySQL you can do '[0-9]*', but this doesn't work on SQL Server. Can anyone point me in the direction of an equivalent or confirm that it cant happen/i am approaching it wrong?
Edit: I have to use a constraint, per the assignment requirements.