I was looking for a stored procedure for SQL server 2005 to remove leading, trailing and other spaces of records stored in the table.
Basically, I needed to bulk insert data into my Database, and the table that I am working on contains blank spaces in various records. Take an instance of Pincode/Zip code, that cannot have spaces between them but the data I have inserted had spaces in most of the pincodes like “110 001“, however it should be “110001“. In other columns the data is in form of ” data ” where it should be “data“
I have already inserted the data but, I need to format it now, so as to arrange it in proper form.
You should use REPLACE . Try
REPLACE(Pincode, ' ', '')UPDATE:
If you need to update data in a table