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.
Author |
Topic |
Rimsky
Starting Member
12 Posts |
Posted - 2007-06-12 : 11:14:52
|
I have a dataset which needs converting from VarChar to Int. On first inspections values seemed to be 64000, 64051, etc. Upon running the query I found values like '64SEAF'. This fails my converting it.It boils down to this:DECLARE @n VarChar(100)DECLARE @intResult IntSET @n = '64SEAF'SET @intResult = CONVERT(Int, @n)print @intResultThis gives me:Msg 245, Level 16, State 1, Line 4Conversion failed when converting the varchar value '64SEAF' to data type int.How do I effectively convert the VarChar '64SEAF' to an Int. The result would preferably be 64.Tnx for any insights.Cees Cappelle |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
Rimsky
Starting Member
12 Posts |
Posted - 2007-06-12 : 12:03:21
|
Thank you for the tip. That'll work.Cees |
 |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-06-12 : 12:04:54
|
What do you want to do with '64SEAF24'?If you want 64 from that then it'sleft(str, patindex('%[^0-9]%',str)-1)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|