That depends completely on the underlying data source. For SQL Server
2000 and below, you can use the syscolumns table. For SQL Server 2005,
sys.columns is recommended. If you are using another database system, then
that will have its own way of retreiving this info.
You can create a connection and then call the GetSchema method on it.
However, the way that the schemas are defined and what they return are
provider-specific, so you will need to have some knowledge beforehand.
"RP" <rpk.general@gm ail.comwrote in message
news:1188320271 .928794.96010@q 5g2000prf.googl egroups.com...
>I want to retrieve column names (Exact field names) of a table. How to
do that?
>
Depends on the DBMS (if those are the "column"s and "table"s you are
referring to). If SQL Server 2000, you can call the FillSchema method or
execute the sp_columns stored procedure on the server itself.
Yes, as Mythran stated, you can execute the sp_columns stored procedure,
or you can perform a select against sys.columns (where the object_id is the
id of the table you want to get the columns for).
On Aug 28, 10:40 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
..... you can execute the sp_columns stored procedure,
or you can perform a select against sys.columns (where the object_id is the
id of the table you want to get the columns for).
On Aug 28, 1:30 pm, RP <rpk.gene...@gm ail.comwrote:
I am using SQL Server 2005. Can it be retrieved using SQL?
The "safest" way to get metatdata from SQL Server like table list and
column lists is to use one of the INFORMATION_SCH EMA Views. For a list
of tables in the current database:
On Aug 28, 1:30 pm, RP <rpk.gene...@gm ail.comwrote:
>I am using SQL Server 2005. Can it be retrieved using SQL?
>
The "safest" way to get metatdata from SQL Server like table list and
column lists is to use one of the INFORMATION_SCH EMA Views. For a list
of tables in the current database:
>
select * from information_sch ema.tables
SELECT COLUMN_NAME
FROM INFORMATION_SCH EMA.COLUMNS
WHERE TABLE_NAME='xxx x'
That depends completely on the underlying data source. For SQL Server
2000 and below, you can use the syscolumns table. For SQL Server 2005,
sys.columns is recommended. If you are using another database system, then
that will have its own way of retreiving this info.
>
You can create a connection and then call the GetSchema method on it.
However, the way that the schemas are defined and what they return are
provider-specific, so you will need to have some knowledge beforehand.
Using INFORMATION_SCH EMA's should be the recommended way.
Seems rather silly to use a database specific function to
do something that is standardized.
Comment