DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

SQL Columns Metainfo With References

  • submit to reddit
        CREATE VIEW dbo.vw_XL_TableColumnDetails  
SELECT     tCols.TableName, tCols.ColumnName, tCols.TypeName, tCols.MaxLength, tCols.precision, tCols.scale, tCols.IsPrimaryKey, tCols.IsNullable, tCols.IsIdentity,   
                      tCols.IsComputed, tCols.ColumnOrder, tRef.SourceTable, tRef.SourceColumn  
FROM         dbo.vw_XL_TableColumns AS tCols LEFT OUTER JOIN  
                      dbo.vw_XL_TableReferences AS tRef ON tCols.TableName = tRef.TargetTable AND tCols.ColumnName = tRef.TargetColumn