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
 General SQL Server Forums
 New to SQL Server Programming
 Empty Space

Author  Topic 

satheesh
Posting Yak Master

152 Posts

Posted - 2012-09-21 : 06:10:10
Dear All,

I am trying to remove any space in 'postcode' field to re update without space.But not working perfectly.

for Ex

TW9 7HJ - TW97HJ
GU32 9TY - GU329TY

The space be in middle of any letter.How to replace and merge.Any help will be highly appreciated.

Thanks
GS

satheesh
Posting Yak Master

152 Posts

Posted - 2012-09-21 : 06:16:14
I found a solution.Its working!!
cast(replace(Postcode,' ','') as char(10))
Thanks
Go to Top of Page

sql-programmers
Posting Yak Master

190 Posts

Posted - 2012-09-21 : 06:23:38
DROP TABLE #tt
CREATE TABLE #tt ( NAME VARCHAR(50) )

INSERT INTO #tt
( NAME )
VALUES ( 'TW9 7HJ' -- NAME - varchar(50)
)
INSERT INTO #tt
( NAME )
VALUES ( 'GU32 9TY' -- NAME - varchar(50)
)
SELECT *
FROM #tt

UPDATE #tt
SET NAME = REPLACE(NAME, ' ', '')

SELECT *
FROM #tt

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-09-21 : 06:26:37
Simply,

UPDATE YourTable SET Postcode = REPLACE(Postcode,' ', '')


In your solution you are missing some characters at the end



--
Chandu
Go to Top of Page
   

- Advertisement -