Error!
Success!

T-SQL Function to Get Int From Varchar

0
kicks

T-SQL Function to Get Int From Varchar  (Unpublished)

I recently had to write a T-SQL function which cleans up all non numeric characters from a varchar variable and returns the int value of the remaining numeric characters. If no numeric characters exist, the function should return zero. I thought it would be nice to share this with you and I hope you find this useful ;-) Expected output of the function: PRINT dbo.GetIntFromVarchar('R1A2J3') -- returns 123 PRINT dbo.GetIntFromVarchar('COOL456CODER') -- returns 456 PRINT dbo.GetIntFromVarchar('789') -- returns 789 PRINT dbo.GetIntFromVarchar('GEEK') -- returns 0


Kicked By:
Drop Kicked By: