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)
 Conversion of an ID

Author  Topic 

1sabine8
Posting Yak Master

130 Posts

Posted - 2009-06-01 : 04:46:47
Hi,
I have an id in this form:2321-8794-8777
I need to know how i can remove the '-' from it and convert the result to int.
How can this be done in the query?
Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-01 : 04:48:54
SELECT CAST(REPLACE(Col1, '-', '') AS BIGINT)



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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-01 : 04:49:31
you will need bigint for that

select convert(bigint, replace('2321-8794-8777', '-', ''))



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

Go to Top of Page
   

- Advertisement -