View the primary key of a table in a library, identify columns, computed columns, field types, allow nulls, default values, and other properties
SELECT [Table name]= Case whent.column_id= 1 Then object_nameT.object_id)ELSE "' END , [Field Number]=t.column_id,[Field name]=T.name,[PRIMARY Key]= Case when exists(SELECT 1 fromSys.key_constraintswhereType='PK' and object_id=T.object_id) Then '●' ELSE "' END, [identity Column]= CaseT.is_identity when 1 Then '●' ELSE "' END, [Computed Columns]= Caset.is_computed when 1 Then '●' ELSE "' END, [field Type]=(SELECTName fromSys.typesWHEREuser_type_id=t.user_type_id),[Field Length]=T.PRECISION, [Decimal digits] =T.scale,[Allow empty] = CaseT.is_nullable when 1 Then '●' ELSE "' END, [Default Value]= ISNULL((SELECTDefinition fromSys.default_constraintswhere object_id =T.DEFAULT_OBJECT_ID),"'), [Field Description]=(SELECTVALUE fromSys.extended_propertiesWHEREmajor_id=T.object_id andminor_id=t.column_id) fromsys. COLUMNS TINNER JOINSys.objects O onT.object_id =O.object_id andO.type= 'U' WHERE Right(object_nameT.object_id),3)<> 'Log' and object_nameT.object_id)<>'auditddlevents' and object_nameT.object_id)<>'dtproperties' ORDER by object_nameT.object_id), t.column_id
View the primary key of a table in a library, identify columns, computed columns, field types, allow nulls, default values, and other properties