IF OBJECT_ID ('dbo.POOrderDefinition','V') IS NOT NULL DROP VIEW dbo.POOrderDefinition
GO 
CREATE VIEW dbo.POOrderDefinition
AS
SELECT 
	c.column_id as ColumnID,
    c.name as ColumnName,
    t.name as DataType,
    c.max_length AS MaxLength,
    c.precision AS PrecisionValue,
    c.scale AS ScaleValue,
    CASE WHEN c.is_nullable = 1 THEN 'YES' ELSE 'NO' END as IsNullable,
    CASE WHEN ic.is_identity = 1 THEN 'YES' ELSE 'NO' END as IsIdentity, 
    dc.definition as ColumnDefault
FROM 
    sys.columns c
JOIN 
    sys.types t ON c.user_type_id = t.user_type_id
LEFT JOIN 
    sys.identity_columns ic ON c.object_id = ic.object_id AND c.column_id = ic.column_id
LEFT JOIN 
    sys.default_constraints dc ON c.default_object_id = dc.object_id
WHERE 
    c.object_id = OBJECT_ID('POOrder')