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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select null of column

Author  Topic 

Gili
Starting Member

42 Posts

Posted - 2007-06-28 : 05:26:26
Hi,
i wanna retrieve number of null column in table .

what is the way to do this?


thanks.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-28 : 05:31:57
Number of Null column? What do you mean? Count of Null values?



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Gili
Starting Member

42 Posts

Posted - 2007-06-28 : 05:33:20
yes count of null values in table.
10x.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-28 : 05:36:03
[code]Select count(*) from table where column is NULL[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Gili
Starting Member

42 Posts

Posted - 2007-06-28 : 05:38:51
i write this query :

Select count(*) from Tbl_014_Accounting
where column is NULL

and i get this err:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'column'.

i don't know the reason.??
10x.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-28 : 05:43:24
Replace column by actual column name

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Gili
Starting Member

42 Posts

Posted - 2007-06-28 : 05:44:49
ammm...
i'm looking for retrieve count of all column that are they null in table.

can i do that.???
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-06-28 : 05:50:21
[code]SELECT SUM(CASE WHEN Col1 IS NULL THEN 1 ELSE 0 END) AS Col1,
SUM(CASE WHEN Col2 IS NULL THEN 1 ELSE 0 END) AS Col2,
SUM(CASE WHEN Col3 IS NULL THEN 1 ELSE 0 END) AS Col3,
SUM(CASE WHEN Col4 IS NULL THEN 1 ELSE 0 END) AS Col4,
SUM(CASE WHEN Col5 IS NULL THEN 1 ELSE 0 END) AS Col5
FROM Table1[/code]

Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -