{"id":174,"date":"2012-04-24T09:34:24","date_gmt":"2012-04-24T09:34:24","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/04\/24\/script-to-strip-non-numeric-characters-from-string\/"},"modified":"2012-04-24T09:34:24","modified_gmt":"2012-04-24T09:34:24","slug":"script-to-strip-non-numeric-characters-from-string","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/04\/24\/script-to-strip-non-numeric-characters-from-string\/","title":{"rendered":"Script to Strip Non Numeric Characters from string"},"content":{"rendered":"

Below sample script strips (removes) non numeric Characters from string (varchar)<\/p>\n

[sql]
\nDECLARE @VARCHARString VARCHAR(8000)<\/p>\n

SET @VARCHARString = ‘000012W`”ASDASDS3A@!#@!#_)+)_4)’<\/p>\n

SELECT @VARCHARString<\/p>\n

–Remove non numeric charecters from the varchar variable
\nWHILE PATINDEX(‘%[^0-9]%’, @VARCHARString) > 0
\n SET @VARCHARString = STUFF(@VARCHARString, PATINDEX(‘%[^0-9]%’, @VARCHARString), 1, ”)<\/p>\n

SELECT @VARCHARString
\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"

Below sample script strips (removes) non numeric Characters from string (varchar) [sql] DECLARE @VARCHARString VARCHAR(8000) SET @VARCHARString = ‘000012W`”ASDASDS3A@!#@!#_)+)_4)’ SELECT @VARCHARString –Remove non numeric charecters from the varchar variable WHILE PATINDEX(‘%[^0-9]%’, @VARCHARString) > 0 SET @VARCHARString = STUFF(@VARCHARString, PATINDEX(‘%[^0-9]%’, @VARCHARString), 1, ”) SELECT @VARCHARString [\/sql]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1789],"tags":[1790,1791],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/174"}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}