Monday, March 26, 2012

How can I print column name only from table?

Is there some Sp out there?select column_name
from information_schema.columns where
table_name = 'tbl1'
tbl1 is the table for which you want to find the list of columns.
Hope this is what you want.
--
"coke" wrote:

> Is there some Sp out there?|||coke,
Check the view INFORMATION_SCHEMA.COLUMNS.
Example:
use northwind
go
select TABLE_NAME, COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'dbo' and TABLE_NAME = 'Orders'
order by ordinal_position
go
AMB
"coke" wrote:

> Is there some Sp out there?sql

No comments:

Post a Comment