Fareeda Hussain

Fareeda Hussain

  • NA
  • 93
  • 92.4k

how can I fetch column name and its data using query?

Dec 22 2016 4:18 AM
Hi
Can I retrieve the column name and its particular data as two column values .Its possible to fetch column name from INFORMATION_SCHEMA.COLUMNS.Can we get
the data also with the same query like
set @tsql = 'select '+@col +' = Column_name,(select @col from @tablename)
from INFORMATION_SCHEMA.COLUMNS
where Table_name like '''+@tablename+'''
exec(@tsql);
.Or can we put for loop inside the stored procedure

Answers (1)