I have a table in which there is a column that has a product value, but some (very few) rows have text mixed in the column.
Is it possible to create a new decimal type column and fill it with another column and just ignore rows with βbadβ data in it?
I know I can do this with code, but was hoping I could do it with an SQL query in some way?
You can use case to distinguish only whole columns. This will return NULL for non-numeric columns:
select case when isnumeric(col1) = 1 then cast(col1 as int) end from YourTable
:
select * from YourTable where isnumeric(col1) = 1
, , .
1:
(9, 2) (PriceOfItem) (ItemPrices)
2. ( )
Update ItemPrices Set PriceOfItem = Convert (Decimal (9, 2), PriceText) Where 1=1 AND IsNumeric (PriceText) = 1
How does this sound? I use it all the time. Simple and fast.
NewColumn: iif( isnumeric([OldColumn]), cdbl([OldColumn]) )
Source: https://habr.com/ru/post/1736147/More articles:Finding SQL Server Restore from inside C # - c #Reset Java applet on reboot - javaHow to change String value after 5 seconds? - c #Unsynchronized getter / setter behavior in Java - javaError trying to convert image <1 MB in App Engine - google-app-engineWhat are the sizes of the largest used JPEG image in GAE? - google-app-engineSeveral drivers for usb device - usbC #: create a new single image that repeats another image x times horizontally - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1736151/parameters-to-tune-when-retrieving-a-lot-of-small-blobs-2-10kb-from-oracle-db&usg=ALkJrhjsB8pQqTiJVcA3vmU255nsmKv-7wHow to pay only the dependency penalty for the implementation you use in Python? - pythonAll Articles