sql server - SQL: Select columns with NULL values only -


how select columns in table contain null values rows? i'm using ms sql server 2005. i'm trying find out columns not used in table can delete them.

here sql 2005 or later version: replace addr_address tablename.

declare @col varchar(255), @cmd varchar(max)  declare getinfo cursor select c.name sys.tables t join sys.columns c on t.object_id = c.object_id t.name = 'addr_address'  open getinfo  fetch next getinfo @col  while @@fetch_status = 0 begin     select @cmd = 'if not exists (select top 1 * addr_address [' + @col + '] not null) begin print ''' + @col + ''' end'     exec(@cmd)      fetch next getinfo @col end  close getinfo deallocate getinfo 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -

jquery - How can I dynamically add a browser tab? -