Hey guys,
I'm trying to get the column names from a table to which I'm connected
through OBDC. I don't want to use linked server. I get my data with
Openrowset.
I found the SQLDescribeCol and SQLColumns ODBC functions.
Can anybody tell me how to use those functions in a SQL Server stored
procedure?
Thanks a lotHi Pumkin,
should work as follows
SELECT colId, name,
FROM dbo.sysObjects
WHERE Id = OBJECT_ID('YourTableName')
ORDER BY ColId
HTH ;-)
Gru, Uwe Ricken
MCP for SQL Server 2000 Database Implementation
GNS GmbH, Frankfurt am Main
http://www.gns-online.de
http://www.memberadmin.de
http://www.conferenceadmin.de
________________________________________
____________
dbdev: http://www.dbdev.org
APP: http://www.AccessProfiPool.de
FAQ: http://www.donkarl.com/AccessFAQ.htm|||Hey,
I should explain myself better... I need to get the column names of a
table given as parameter. There is COLUMN_NAME from INFORMATION_SCHEMA
for SQL Server. The problem is that my table is not on my server and is
not a SQL Server table either. I need to access it through ODBC.
Can anybody help? Thanks|||Pumkin wrote:
> Hey,
> I should explain myself better... I need to get the column names of a
> table given as parameter. There is COLUMN_NAME from INFORMATION_SCHEMA
> for SQL Server. The problem is that my table is not on my server and
> is not a SQL Server table either. I need to access it through ODBC.
> Can anybody help? Thanks
It is not possible to use the ODBC functions you mentioned from a stored
procedure which can only run queries via openrowset.
If the table is in a relational database, then it should be possible to run
a query against that database to get the column names. Without more specific
information, it is impossible to go into details. Maybe you should try a
newsgroup devoted to the rdbms you are linking to.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||Hy Bob,
Thanks for the reply. The database that I am connecting to in not
relational. But I found something now...
It works if I do "select * from table where 1=2"
But I was looking for something more dynamically build.|||Pumkin wrote:
> Hy Bob,
> Thanks for the reply. The database that I am connecting to in not
> relational. But I found something now...
> It works if I do "select * from table where 1=2"
> But I was looking for something more dynamically build.
I'm not sure how that helps you: your t-sql code is not going to be able to
read those column names. I was thinking that you needed your code to somehow
use those column names for something.
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment