T-SQL Function to Get Int From Varchar(codeforeternity.com)

submitted by xtremebizxtremebiz(575) 4 years ago

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

add a comment |category: |Views: 43

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story