View Column Names of Each Database in SQL Server 2012
In this article I describe how to View list of column names of each database stored in SQL Server.
In this article I describe how to show column names of each database stored in SQL Server. Sometimes we need to find all the column names in SQL Server. To show all the column names list, we have stored procedure named "sp_msforeachdb". In my previous article I described how to use Sp_msforeachdb. You can visit from here- sp_MSforeachdb Stored Procedure in SQL Server 2012. Run below code to view column names:
declare @cmd varchar(500)
set @cmd='SELECT name as ColumnName FROM ?.SYS.COLUMNS'
exec SP_MSFOREACHDB @cmd
Show list of all columns in a particular database
Run following code to give table column names as rows. Here table name is "e".
select column_name 'All_Columns'
from information_schema.columns where table_name='e'