Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMP1
- CMP01
- CMP10000
- CMP999999
- CMPdog1
- steve
- 1CMP1
- 1
- 999999999
- IDCompany LIKE 'CMP%[0-9]'
- IDCompany LIKE 'CMP[0-9]' OR IDCompany LIKE 'CMP[0-9][0-9]' OR .... through to 6 characters
- EDIT 1:
- This solution ended up working for me:
- IDCompany nvarchar(9) NOT NULL CONSTRAINT DEF_Company_IDCompany DEFAULT 'CMP' + CAST((NEXT VALUE FOR dbo.sq_Company) AS nvarchar) CONSTRAINT CHK_Company_IDCompany CHECK (IDCompany LIKE 'CMP%[0-9]' AND ISNUMERIC(SUBSTRING(IDCompany,4,LEN(IDCompany)-3))=1)
- where LEFT(IDCompany, 3) = 'CMP'
- and isnumeric(RIGHT(IDCompany, len(IDCompany) - 3)) = 1
- and IDCompany not like '%[.,-]%'
- isnumeric(substring(IDCompany,4,len(IDCompany)))=1 and IDCompany not like '%[.,-]%'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement