Script for null
Up to DB2Script for null
Posted by santhosh babu at July 17. 2008nedd a script for null checking in the database. The following is the format I am expecting.
Table Name Column Name Total Records in Table Null Records for this column
------------------------ -------------------------- --------------------------------------- -----------------------------------------
Emp Empno 300 50
Re: Script for null
Posted by Saurabh at August 21. 20081. Easy way:
In DB2 9.5, use this query " select substr(a.tabname,1,30) as tabname,substr(a.COLNAME,1,30) as colname,b.card,a.NUMNULLS from syscat.columns a, syscat.tables b where a.tabname = b.tabname and a.TABSCHEMA = b.TABSCHEMA "
2. Hard way:
Consider this table,
A
-----------
1
2
3
4
-
1
2
3
4
-
1
2
3
4
-
15 record(s) selected.
Issuing the query " select x.a,x.cnt,x.sumcnt from (select a,count(1) as cnt ,sum(count(1)) over() as sumcnt from sj1 group by a) as x where x.a is null "
A CNT SUMCNT
----------- ----------- -----------
- 3 15
1 record(s) selected.
You can use this to create a script.
OR,
Re: Script for null
Posted by Saurabh at August 21. 2008Oh, just one more thing, for the first query to give you a good result, ensure that your statistics are updated.