Home Forums SQL Server 7,2000 T-SQL Counting "incomplete" fields in tables RE: Counting "incomplete" fields in tables

  • Hi HallD

    you could try using substring to return the column name as follows :-

    create table incomplete_test

    (col1 int , col2 varchar(10))

    insert into incomplete_test

    values (0, "A")

    insert into incomplete_test

    values (0, "")

    insert into incomplete_test

    values (0, null)

    insert into incomplete_test

    values (1, "A")

    insert into incomplete_test

    values (1, "")

    insert into incomplete_test

    values (1, null)

    and then use the following select (replacing col1 & col2 with your own column name):-

    select substring('col1', 10 *col1 , 10) + " " + substring('col2', 10*len(isnull(col2,"")), 10) from incomplete_test

    all int columns need to be handled by substring('col1', 10 *col1 , 10)

    all varchar columns need to be handled by

    substring('col2', 10*len(isnull(col2,"")), 10)

    it's a bit crude, but it'll get you started

    Paul