
Getting the source table from a recordset field?
Hello Ray:
You can do a couple of things that I'm familiar with:
1. Create a recordset that returns the table names using
the following SQL query I wrote against the Northwind
database in SQL Server 2k. It should work fine in 7.0
also.
Query:
select syscolumns.name, sysobjects.name
from syscolumns, sysobjects
where syscolumns.name = 'customerid'
and syscolumns.id = sysobjects.id
The above query returns the column name and each table
associated with each column with the same name. In other
words, the column "customerid" exists in more than one
table in the Northwind database.
or you can use the SQL-DMO object library which is what
MSFT recommends as opposed to hitting the system tables
directly because they can change and therefore break your
query. It's a bit slower, but at least you have a nice
object model to use.
Quote:
>-----Original Message-----
>I have an ADO recordset and would like to determine the
source of a column
>(the table name). I'm using SQL 7.0. Is there a way I can
do this?
>Thanks,
>Ray
>.