Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query help

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-03-05 : 08:01:52
I NEED TO DELETE IF THERE IS SOME NON NUMERICDATA IN TABLE ID COLUMN, I HAVE CREATED THIS AS VARCHAR BUT NOW WANT TO DELETE ALL NON NUMERIC VALUES

challenge everything

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-05 : 08:03:48
Use this if you want to DELETE the entire row.
DELETE FROM YourTable WHERE ISNUMERIC(theVarcharCol) = 0;
There are some caveats - for example ISNUMERIC('-') returns 1.If you just want to update non-numeric rows and set the value to NULL use this
UPDATE YourTable SET theVarcharCol = NULL WHERE ISNUMERIC(theVarcharCol) = 0;
Go to Top of Page
   

- Advertisement -