0

I have been trying to get the rows where cell is empty but how can i get an empty cell Its not NULL over there, its like an empty string.

05J9LJ-E    E004030 BGH/F.TB
            E004032 000080.KS
002X87-E    E004033 018880.KS

So second row, first column is like 8 spaces so how can i get these rows

SELECT column_A,column_B,column_C FROM [dbo].[table] where column_A is null

SELECT column_A,column_B,column_C FROM [dbo].[table] where column_A = ''

When i put the dataNotepad View in notepad++

1
  • The syntax is clearly SQL Server so I removed the mysql tag. Commented Jan 20, 2015 at 12:02

2 Answers 2

1

You can check that there are no non-space characters in the value:

SELECT column_A, column_B, column_C
FROM [dbo].[table] 
WHERE column_A is null OR
      column_A NOT LIKE '%[^ ]%'

This has the advantage that you can include other characters besides spaces, if you need to.

Sign up to request clarification or add additional context in comments.

Comments

1

You can check if they are NULL or spaces by using an OR between both conditions:

WHERE column_A IS NULL
  OR  column_A = ''  -- includes multiple spaces

3 Comments

i tried it but its not working, may be there are some extra characters in between
LTRIM(RTRIM(column_A)) = '', isn't that exactly the same as column_A = '' ?
@t-clausen.dk: you're right :) Edited my answer to take it into account.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.