SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Creating a Script to add or remove spaces
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jwarren
Starting Member

USA
1 Posts

Posted - 05/24/2012 :  16:18:57  Show Profile  Reply with Quote
Does anyone know of a way to add or remove spaces after commas with a script? I have a SQL Database that is setup with this format: Lastname,Firstname and another Database that uses this format: Lastname, Firstname. I'd like to be able to add the space so they are uniform. Any thoughts?

Thanks!

Jonathan Warren

Edited by - tkizer on 05/24/2012 16:43:31

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 05/24/2012 :  16:58:47  Show Profile  Visit tkizer's Homepage  Reply with Quote
--remove the space
UPDATE t1
SET c5 = REPLACE(c5, ', ', ',')

--add the space
UPDATE t1
SET c5 = REPLACE(c5, ',', ', ')

You should really consider separating the data into two columns though. Putting them in one column is bad design.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000