sysconstraints question | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

sysconstraints question

Hi, I have 2 catalog tables and 1 info tables, how can I get the catalog for a specific field dinamically for example[:I]<br /><br />-table1<br /> + id<br /> + name<br /> + number<br /> + id_department<br /> + id_degree<br /><br />-departments<br /> + id_deparment<br /> + name<br /><br />-degrees<br /> + id_degree<br /> + name<br /><br />if the user cliks on the deparment field how can I find out witch table it’s related to, i tried …<br /><pre id="code"><font face="courier" size="2" id="code"><br />SELECT * FROM SYSCONSTRAINTS <br />WHERE <br />COLID IN (<br />SELECT colid <br />FROM SYSCOLUMNS <br />WHERE NAME=’id_deparment’) AND<br />ID NOT IN (<br />SELECT ID<br />FROM SYSOBJECTS<br />WHERE NAME=’dtproperties’)</font id="code"></pre id="code"><br /><br />but it gives me 2 rows [xx(]<br /><br />constid id colid spare1 status actions error <br />———– ———– —— —— ———– ———– ———– <br />1205579333 869578136 7 0 2067 4096 0<br />1125579048 1077578877 10 0 2067 4096 0<br /><br /><br />how do I know wich one is the one containing all the departments?<br /><br />i want it to be dynamic cus’ this is for 1 field only, but in the real program there’s gona be more and I dont want it to depend on the table names.[?]<br /><br />German [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]
Select table_name from information_schema.columns where column_name=’yourCol’ Madhivanan Failing to plan is Planning to fail
]]>