replace space ' ' from column

  • CREATE TABLE TEST(name varchar(50));

    INSERT INTO TEST VALUES('My Name IS');

    INSERT INTO TEST VALUES('YOUR Name IS');

    INSERT INTO TEST VALUES('THIS IS SAMPLE');

    OUTPUT:

    My Name IS

    YOUR Name IS

    THIS IS SAMPLE

    I want to update a table to remove space in string.AND OUTPUT LIKE

    OUTPUT:

    MyNameIS

    YOURNameIS

    THISISSAMPLE

  • Try this

    Update Test set name = replace(name,' ','')

  • the REPLACE command is what you want:

    SELECt Replace(columnname,' ','') As Columname from YourTable

    it might be hard to see, but the command is singlequote-space-singlequote for WHAT to replace, and is two single quotes with nothing between them for the replace with an empty string

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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