Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
SELECT TOP 1 txt_root FROM support_DBWHERE num_parent=0ORDER BY CONVERT(int,txt_root) desc
And I'm getting this error:
Conversion failed when converting the varchar value '001.001' to data type int.
Thanks for your help!
spirit1
Cybernetic Yak Master
11752 Posts
Posted - 2006-09-16 : 14:17:57
you can only have one . in the varchar you want to convert to int.try ORDER BY CONVERT(int, REPLACE(txt_root, '.', ''))Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2006-09-19 : 05:36:22
or you can rightpad the txt_root column values.SELECT TOP 1 txt_root FROM support_DBWHERE num_parent=0ORDER BY RIGHT(REPLICATE('0', 200) + txt_root, 200) descPeter LarssonHelsingborg, Sweden