richardandro
asked on
Cleanup trailing spaces from multiple fields
I am in need of a solution to a problem which I have inadvertently created during my build of my MS SQL 2008 database. I have multiple tables, each with multiple fields which may contain data with trailing and possibly leading spaces. I am looking for a function/procedure/stateme nt which will loop through every char/nvarchar field and eliminate the offending spaces.
I am aware that I can individually run Update statements using RTRIM/LTRIM for each field name. However, because I have hundreds of such fields I am hoping that someone has a more automated way to cleanup a whole table once. It would most likely process field 1 through field n and if the field is char/nvarchar then the update statement will execute for that field, otherwise it will go to the next field.
Ideas?
I am aware that I can individually run Update statements using RTRIM/LTRIM for each field name. However, because I have hundreds of such fields I am hoping that someone has a more automated way to cleanup a whole table once. It would most likely process field 1 through field n and if the field is char/nvarchar then the update statement will execute for that field, otherwise it will go to the next field.
Ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER