Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to remove spaces

Author  Topic 

kiranmurali
Yak Posting Veteran

55 Posts

Posted - 2010-07-15 : 02:06:20
i have input field like'CASUAL LEAVE' that will be done in the front end, but while storing in the backend(SQL SERVER 2008) it should not contain any spaces. it should store like(CASUALLEAVE).

Is there any built in function?


Thanks in Advance,
Kiran

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-15 : 02:44:14
replace all spaces by nothing:

replace('your value',' ','')

or

replace(your_columnname,' ','')



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-07-15 : 03:06:18
replace(your_columnname,' ','')

perhaps combine with

WHERE your_columnname LIKE '% %'

to only update (and log ...) rows that actually need changing.
Go to Top of Page
   

- Advertisement -