You'll probably want to look into using the INFORMAITON_SCHEMA table (that exists with any database in SQL Server). You'll need to play with it but here's something that will get you started:
select * from information_schema.tables t inner join information_schema.[columns] c on t.TABLE_CATALOG = c.TABLE_CATALOG where t.table_catalog='ServiceTech' and t.table_schema='dbo' and t.table_type='BASE TABLE' and t.table_name <> 'users' and t.table_name <> 'lvl' and (c.column_name = 'users_k' or c.column_name='lvl_k') order by t.table_type HTH Hatton Schreck, Tom wrote: > I need a stored procedure that accepts 2 table names and determines if there's a >table between them that houses each table's primary key. In other words, I need to >find the table that joins 2 tables together in a many-to-many relationship, if it >exists. Has anyone done something similar to this? > > Thanks - Tom > > ------------------------------------------------------------------------- > This email server is running an evaluation copy of the MailShield anti- > spam software. Please contact your email administrator if you have any > questions about this message. MailShield product info: www.mailshield.com > > ----------------------------------------------- > To post, send email to [EMAIL PROTECTED] > To subscribe / unsubscribe: http://www.dfwcfug.org > > ------------------------------------------------------------------------- This email server is running an evaluation copy of the MailShield anti- spam software. Please contact your email administrator if you have any questions about this message. MailShield product info: www.mailshield.com ----------------------------------------------- To post, send email to [EMAIL PROTECTED] To subscribe / unsubscribe: http://www.dfwcfug.org
