Say I have the following table:
Tree Park Slide
1 1 1
1 1 1
1
1 1
What kind of code would I use to remove the rows that have empty columns such that I would just have the following result
Tree Park Slide
1 1 1
1 1 1
I am new to sql and was wondering on some tips on how to write this code. Would I use a case statement such that
Case
WHEN Tree IS NULL OR Park IS NULL
--Then what would I say to remove the row
Use DELETE to delete a row and check it with IS NULL in the WHERE clause.
DELETE FROM dbo.TableName
WHERE Tree IS NULL OR Park IS NULL OR Slide IS NULL
If you also want to delete rows where one of these columns is not null but empty text(if it's a varchar column):
DELETE FROM dbo.TableName
WHERE (Tree IS NULL OR Tree = '')
OR (Park IS NULL OR Park = '')
OR (Slide IS NULL OR Slide = '')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With