[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

How do I creat a check constraint to prevent updates/insertions of certain characters?

I want to create a check constraint on a table to prevent updates/insertions of certain characters.  I tried this but did not work:  name not like '%<%>%'.
0
Jack Seaman
Asked:
Jack Seaman
1 Solution
 
tigin44Commented:
As I understand you want to prevent the enter of "<" and ">" characters so try this

PATINDEX('%[<->]%', 'ABC>D<EF') = 0
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
ALTER TABLE dbo.tablename ADD CONSTRAINT
      CK_activities CHECK (name not like '%<%>%')
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now