Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. CMP1
  2. CMP01
  3. CMP10000
  4. CMP999999
  5.  
  6. CMPdog1
  7. steve
  8. 1CMP1
  9. 1
  10. 999999999
  11.  
  12. IDCompany LIKE 'CMP%[0-9]'
  13.  
  14. IDCompany LIKE 'CMP[0-9]' OR IDCompany LIKE 'CMP[0-9][0-9]' OR .... through to 6 characters
  15.  
  16. EDIT 1:
  17. This solution ended up working for me:
  18.  
  19. 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)
  20.  
  21. where LEFT(IDCompany, 3) = 'CMP'
  22. and isnumeric(RIGHT(IDCompany, len(IDCompany) - 3)) = 1
  23. and IDCompany not like '%[.,-]%'
  24.  
  25. isnumeric(substring(IDCompany,4,len(IDCompany)))=1 and IDCompany not like '%[.,-]%'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement