2009/08/04

SQL- List out all the columns in a table

Assume that you wish to check for rows in a table where all values are NULL. There are many columns in the table and you want to avoid hand coding them. Instead, you can create a script to do the work for you:

Select column_name + ' IS NULL AND'
FROM INFORMATION_SCHEMA.columns
where table_name = 'whatever'

Enjoy! this query is very useful ;)

No comments:

Post a Comment