[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2146
  • Last Modified:

SQL Server remove all spaces in data

I get "extracted date" that has a field that end users place their zipcodes in.

Unfortunately there are a lot of records with spaces in the zipcode field WITH the zipcode

'     99032'
' 99033       '
'99034'

I need to strip ALL spaces.  Is there an update I can run?
0
lrbrister
Asked:
lrbrister
  • 2
2 Solutions
 
gpompeCommented:
update table
set field = rtrim(ltrim(field))
0
 
mcmonapCommented:
Hi lrbrister,

try something like this:
UPDATE
  YOURTABLE
SET
  zipcode = REPLACE(zipcode, ' ', '')
0
 
mcmonapCommented:
Hi lrbrister,

Note my solution will remove spaces from the middle of zipcodes as well as either end - if you do not want this use gpompe's solution
0
 
lrbristerAuthor Commented:
Hey guys...both are great.  Splitting the points with a tiny bit more to gpompe:
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now