Robertuzzo
Robertuzzo

Reputation: 169

Delete all row in a table where all content are equals to NULL

Based in a table with follow structure:

column1 column2 column3 ... columnN

1 null null null null

How i can delete all the row in the table that contain all null values? (except the 1st column that is an ID column)

Thank you guys

Upvotes: 0

Views: 32

Answers (2)

Durgesh Verma
Durgesh Verma

Reputation: 19

  • Please use the below code:

Delete from tbl1 where ISNULL(column1,'')='' and ISNULL(column2,'')='' and ISNULL(column3,'')=''

Upvotes: 0

Jayesh Goyani
Jayesh Goyani

Reputation: 11154

Please try with below code snippet.

DELETE FROM TableName
WHERE COALESCE (column2,column3,column4) IS NULL;

Upvotes: 1

Related Questions