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 2005 Forums
 Transact-SQL (2005)
 Removing brackets from a column text

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2009-06-17 : 06:32:13
Hi i've a column that as a varchae datatype as 1234 with a brackets each side of the value like (1234)

i need to remove the brakcets but so far i've only used replace() and i need to do this twice in 2 temp tables is there any other way of removing the 2 brackets in one select statement as i need to insert the data into a new table column with the dattype of int.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-17 : 06:36:52
you can do it once with 2 replace()
replace(replace(col, '(', ''), ')', '')



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-17 : 06:39:20
SUBSTRING(Col, 2, LEN(Col) - 2)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2009-06-17 : 06:40:35
Thanks i never though of doing that it works fine..
Go to Top of Page
   

- Advertisement -