Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

make text = NULL when not a integer SQL

$
0
0

Hello all, I am trying to make a view in SQL but a lot of the data is not consistent and I am getting bad data results when I try to divide 2 fields then one of the fields has text in it and not just numbers. Field1 is only numbers but field2 has numbers and text so I want to make it so if any kind of text comes up it is changed to null so that I don't try dividing a number by some text it is makes things very angry.

I was messing around with:

SQL
CASEWHEN[field2]NOTISNUMERIC(dbo.viewdetails.field2)THENdbo.viewdetails.field2=NULLEND
I know it isn't right because I am getting a 'Unable to parse expression' error, but if this helps get my idea of what I am trying to do across then great.

Viewing all articles
Browse latest Browse all 4871

Trending Articles



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