Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Distributed DB Catalogue

Author  Topic 

gl0bb
Starting Member

5 Posts

Posted - 2005-11-26 : 16:09:21
Hi all,

This has been hurting my head all weekend and i am going nowhere any help would be most appreciated.
I have included below a Global Index that has 4 databases under its control.

In order for an application to run a DDL query it need to know the tables location,fragmentation,attributes (and attributes type in a update)
If i use something such as


SELECT A.Attribute_Name
FROM Attribute AS A
WHERE (A.Table_Name = 'Staff')
UNION
SELECT I.Attribute_Name
FROM Indexed_Attribs AS I
WHERE (I.Table_Name = 'Staff')


This gives the expected result but i need Attribute_Name, Attribute_Type, PHF_Local_H_Name, Local_V_Name and this is prooving more difficult



DB_Tables
{PK}
Table_Name No_Attributes Birth_Site

Branch 4 NULL
Product 5 NULL
Staff 11 NULL



Indexed
{FK}
Index_No Table_Name Attribute_Name

1 Branch Branch_No
2 Staff Staff_No
3 Staff Branch_No
4 Product Product_no
5 Product Branch_No



Attributes
{FK} {PK}
Table_Name Attribute_Name Attribute_Type Attribute_Position

Branch Branch_Addr varchar 3
Branch Branch_Name varchar 2
Branch Branch_No int 1
Branch Branch_Tel int 4
Product Product_No int 1
Product Product_Price varchar 4
Product Product_Quantity varchar 3
Product Product_Type varchar 2
Staff Staff_Addr varchar 5
Staff Staff_fName varchar 2
Staff Staff_lName varchar 3
Staff Staff_NI varchar 4
Staff Staff_No int 1
Staff Staff_PSalay int 9
Staff Staff_PTax int 10
Staff Staff_Start_Date varchar 8
Staff Staff_Tel varchar 6
Staff Staff_Title varchar 7



PHF
{PK} {FK}
PHF_Local_H_Name Table_Name Predicate_No

Product_E Product 1
Product_G Product 2
Product_P Product 3
Staff_E Staff 1
Staff_G Staff 2
Staff_P Staff 3
Staff_S Staff 4



VF
{PK} {FK}
Local_V_Name Table_Name Column_No

Staff_E Staff 2
Staff_G Staff 2
Staff_P Staff 2
Staff_S_piv Staff 1



Duplication
{PK} {FK}
Local_V_Name Table_Name Table_No

Branch_E Branch 1
Branch_G Branch 2
Branch_P Branch 3
Branch_S Branch 4

gl0bb
Starting Member

5 Posts

Posted - 2005-11-28 : 05:42:03
possible solution??

?? = Attribute_Name
## = Table_Name

It does seem to return the details needed


SELECT '??',
A.Attribute_Type,
V.VF_Local_V_Name,
V.VF_Column_Number,
P.PHF_Local_H_Name,
P.PHF_Predicate
FROM Indexed_Attribs AS I INNER JOIN
Attribute AS A ON I.Attribute_Name = A.Attribute_Name INNER JOIN
VF AS V ON V.Table_Name = '##' INNER JOIN
PHF AS P ON P.PHF_Local_H_Name = V.VF_Local_V_Name
WHERE (I.Table_Name = '##') AND
I.Attribute_Name = '??'
UNION
SELECT ??,
A.Attribute_Type,
V.VF_Local_V_Name,
V.VF_Column_Number,
P.PHF_Local_H_Name,
P.PHF_Predicate
FROM Attribute AS A INNER JOIN
VF AS V ON V.Table_Name = '##' INNER JOIN
PHF AS P ON P.PHF_Local_H_Name = V.VF_Local_V_Name
WHERE (A.Table_Name = '##') AND
A.Attribute_Name = '??'
Go to Top of Page
   

- Advertisement -