I've got some string stuff that I need to convert to an INT.So I used IsNumeric(@strValue) to make sure there weren't any rogue values.And then some bright-young-spark at the client tried putting "1.1" in.Blow me down if CONVERT from Varchar to Int doesn't fail on that ...So I've resorted to CONVERTing it to FLOAT first, then INT <Snort!>I suppose I could useIF @strValue LIKE '%[^0-9]%' ....to find the non-Ints. I'd have to cope with a leading minus-sign though.Here's an example of what ruined my day:SET NOCOUNT ONGODECLARE @strValue varchar(10), @intLoop intSELECT @intLoop = 1WHILE @intLoop <= 3BEGIN IF @intLoop = 1 SELECT @strValue = '1' IF @intLoop = 2 SELECT @strValue = 'A' IF @intLoop = 3 SELECT @strValue = '0.1' IF IsNumeric(@strValue) = 0 BEGIN SELECT @strValue, 'Not numeric' END ELSE BEGIN SELECT [Value] = @strValue, [With FLOAT] = CONVERT(int, CONVERT(float, @strValue))-- The "1.1" example will fail here: SELECT [Value] = @strValue, [Only INT] = CONVERT(int, @strValue) END SELECT @intLoop = @intLoop + 1ENDGOSET NOCOUNT ONGO
Kristen