Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

SQL Server - replacing patterns

Options
  • 05-05-2009 9:15am
    #1
    Closed Accounts Posts: 910 ✭✭✭


    I'm astounded to find that this does not work (SQLServer 2005 SP1):

    declare @var varchar(50)
    select @var = 'Hewlett-Packard'
    select replace(@var, '[a-z]','?') as Pattern

    expect: 'H??????-P???????'
    get: 'Hewlett-Packard'

    I need to replace all characters with a ? - but within a single SQL statement.. Data is being sent to an Excel file via a SQL statement, so I can't do anything too fancy. Also only have read access to db, so can't create SP's, functions, etc..

    Purpose is to display the pattern distribution of values. for e.g phone numbers 999-999-9999, that sort of thing.


Comments

Advertisement