Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 VALUESchallenge 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;