OK Babu, say you've presented a list of views in your GUI, and the end user selected one of them.
i don't think you need any other parsing DLL at all, all you need is the results of a couple of queries from the server.
the list of columns that are part of the view would simply be this, right?
and here are all the items that have FK references to the underlying tables that are part of my view.
SELECT
objz.name AS TableOrViewName,
colz.name AS ColumnName,
colz.column_id as ColumnOrder,
TYPE_NAME(system_type_id) as DataType
--colz.*
FROM sys.columns colz
INNER JOIN sys.objects objz ON colz.object_id = objz.object_id
WHERE objz.name = 'VW_CITYCOUNTYSTATE'
AND SCHEMA_NAME(objz.SCHEMA_ID) = 'dbo'
now if you want items that reference the underlying tables of the views, so you can match foreign keys, i think it would be something like this:
--the underlying tables of the view
select object_name(referenced_major_id),* from sys.sql_dependencies depz
inner join sys.objects objz
on depz.object_id = objz.object_id
WHERE objz.name = 'VW_CITYCOUNTYSTATE'
AND SCHEMA_NAME(objz.SCHEMA_ID) = 'dbo'
--items that my view references via underlying foreign keys in underlying tables
SELECT *
FROM sys.foreign_keys conz
INNER JOIN sys.foreign_key_columns colz
ON conz.object_id = colz.constraint_object_id
WHERE conz.parent_object_id IN ( SELECT referenced_major_id FROM sys.sql_dependencies depz
INNER JOIN sys.objects objz
ON depz.object_id = objz.object_id
WHERE objz.name = 'VW_CITYCOUNTYSTATE'
AND SCHEMA_NAME(objz.SCHEMA_ID) = 'dbo' )
--items that reference my VIEW via underlying FOREIGN keys FROM underlying tables
SELECT *
FROM sys.foreign_keys conz
INNER JOIN sys.foreign_key_columns colz
ON conz.object_id = colz.constraint_object_id
WHERE conz.referenced_object_id IN ( SELECT referenced_major_id FROM sys.sql_dependencies depz
INNER JOIN sys.objects objz
ON depz.object_id = objz.object_id
WHERE objz.name = 'VW_CITYCOUNTYSTATE'
AND SCHEMA_NAME(objz.SCHEMA_ID) = 'dbo' )
[/ode]
Lowell