SSN datatypes

  • i am trying to create a user defined data type in query anylazer

    so that when i enter a a SSN # i dont have to add the '-'

    here is that syntax i wrote so far but i think i am missing something

    --sp_addtype SSN,'varchar(11)','NOT NULL'

    --GO

    --CREATE RULE ssn_id as @au_id = '[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'

    --GO

    --exec sp_bindrule 'ssn_id','SSN'

    --GO

    can someone please help me.

    yes i am a noob 😀

  • Don't store formatting symbols in the database. The only thing they're good for is display... you'd have to strip them out of most file transfers and reporting and GUI "field tools" all have a default "SSN" type to display a 9 digit SSN correctly. Also, when you actually get around to encrypting this very sensitive column, there's no need to encrypt the dashes.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply