• First, by white space I am going to assume you mean spaces. If you need to include tabs, carriage returns, and perhaps even other nonprinting characters then it gets more complicated. You could of course just keep adding replace functions until you have covered every type of whitespace you need, but if you really mean any whitespace at all, you may want to consider writing something in a CLR/DLR language like C# or IronPython that let you use regex and other more powerful string manipulation for that.

    But if you just mean spaces, and you already have the data inside of sql, then I would use dynamic sql and do something like this:

    (Note: This is untested and written off the cuff)

    declare @sql varchar(8000

    select @sql = 'update YourTableName set'

    --char(10) gives a line break and simply makes it easier to read when proof reading

    select @sql = @sql + column_name + ' = replace(' + column_name + ', '' '', ''''), ' + char(10)

    from infromation_schema.columns

    where table_name = YourTableName

    --Remove the final comma

    select @sql = substring(@sql, 1, len(@sql) -1)

    --Preview the code this generates first

    print @sql

    -- exec @sql --remove the comment marks and let it run the code only after previewing it once

    That should do it if you want to remove all spaces from all columns and all columns are of chracter type. If you want to exclude some columns or have noncharacter columns in there, then add a where clause to the select statement that populates the columns in the @sql statement.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/