Reputation: 81
I have some String fields in BQ that I would like to remove spaces from. In SAS, there is a function compress(). Is there a comparable function in BQ?
WHERE firstname is not null
does not remove those records where there is a single space, for example.
Thanks!
Upvotes: 5
Views: 20154
Reputation: 1057
You may use the REGEXP_REPLACE function mentioned in the Query Reference to remove all spaces.
Use as:
REGEXP_REPLACE('orig_str', 'reg_exp', 'replace_str')
for example:
SELECT REGEXP_REPLACE(' remove all spaces', ' ', '')
returns 'removeallspaces'.
Upvotes: 11