Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL server casting string to integer checking value before casting

$
0
0

i have got a table in database (MS SQL SERVER 2012) called MINIMUM_AGE, the values are inserted as nvarchar i,e 17 years

54 years

N/A

65 years

and so on

i would like to apply where clause on the column to check for certain age range.

so selecting first two characters, then casting them into integer but in the mean time also checking if the value is not N/A before casting, i know i have to use a combination of CAST() and LEFT(MINIMUM_AGE,2) but cant somehow put it all together, any help will be much appreciated



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>