ALTER View [dbo].[ViewSchema] as select v.name ViewName,t.name TableName,vc.name ViewCol,tc.name TableCol from sysdepends d, sysobjects v, syscolumns vc, sysobjects t, syscolumns tc where objectproperty(d.id,'IsView')=1 and d.id=v.id and v.id=vc.id and d.depnumber=vc.colid and d.depnumber=tc.colid and d.depid=t.id and t.id=tc.id
以上,查询视图对应的基表名以及视图字段和对应的基表字段名。
注意:视图中必须有主键字段,否则查出的对应关系可能会错乱!!!