locked
Remove *** from a column RRS feed

  • Question

  • I have a column in a table that has ***data***, how can I remove the *** before and after the data?
    Wednesday, October 28, 2009 5:53 PM

Answers

  • You can use the REPLACE function:

    SELECT REPLACE(column, '***', '')
    FROM Table;

    Here is if you need to update the column:

    UPDATE Table
    SET column = REPLACE(column, '***', '')
    WHERE column LIKE '%***%';

    Plamen Ratchev
    • Proposed as answer by Brad_Schulz Wednesday, October 28, 2009 6:05 PM
    • Marked as answer by Badpig Wednesday, October 28, 2009 6:12 PM
    Wednesday, October 28, 2009 5:57 PM

All replies

  • You can use the REPLACE function:

    SELECT REPLACE(column, '***', '')
    FROM Table;

    Here is if you need to update the column:

    UPDATE Table
    SET column = REPLACE(column, '***', '')
    WHERE column LIKE '%***%';

    Plamen Ratchev
    • Proposed as answer by Brad_Schulz Wednesday, October 28, 2009 6:05 PM
    • Marked as answer by Badpig Wednesday, October 28, 2009 6:12 PM
    Wednesday, October 28, 2009 5:57 PM
  • Use the REPLACE function.
    declare @text as varchar(50)
    set @text = '***DATA***'
    select @text as textValue
    union all 
    select REPLACE(@text,'***','')
    

    Phil Brammer | http://www.ssistalk.com | Twitter: http://twitter.com/PhilBrammer
    • Proposed as answer by Brad_Schulz Wednesday, October 28, 2009 6:05 PM
    Wednesday, October 28, 2009 5:57 PM