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

Posted on 2010-01-05
Last Modified: 2012-05-08
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 '%<%>%'.
Question by:Jack Seaman
    LVL 26

    Expert Comment

    As I understand you want to prevent the enter of "<" and ">" characters so try this

    PATINDEX('%[<->]%', 'ABC>D<EF') = 0
    LVL 75

    Accepted Solution

          CK_activities CHECK (name not like '%<%>%')

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
    In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now