Give this a look as a SQL Server version of desc tablename in MySQL
select C.[name] as [Field]
, concat(TY.[name],
case when TY.name in ('int','bigint','smallint','tinyint','bit') then NULL
when TY.[name] in ('decimal','numeric')then concat('(',cast(C.precision as varchar),',',cast(C.scale as varchar),')')
when TY.[name] in ('money','smallmoney') then NULL
when TY.[name] in ('float') then concat('(',cast(C.precision as varchar),')')
when TY.[name] in ('real') then NULL
when TY.[name] in ('nchar','nvarchar') then concat('(',cast(C.max_length/2 as varchar),')')
when TY.[name] in ('char','varchar') then concat('(',cast(C.max_length as varchar),')')
when TY.[name] in ('date','datetime','smalldatetime') then NULL
when TY.[name] in ('time') then concat('(',cast(C.scale as varchar),')')
when TY.[name] in ('datetime2','datetimeoffset') then concat('(',cast(C.scale as varchar),')')
when TY.[name] in ('text','ntext','image') then NULL
when TY.[name] in ('binary','varbinary') then concat('(',cast(C.max_length as varchar),')')
else TY.[name]
end) as [Type]
, case when C.is_nullable =1 then 'Yes' else 'No' end as [NULL]
, case when (IC.column_id is not null) then 'PRI' else '' end as 'Key'
, DC.definition as [Default]
, case when C.is_identity = 1 then 'auto_increment' end as [extra]
from sys.tables as T
join sys.schemas as S on T.schema_id = S.schema_id
join sys.columns as C on T.object_id = C.object_id
join sys.types as TY on TY.user_type_id = C.user_type_id
left outer join sys.indexes I on T.object_id=I.object_id and I.is_primary_key = 1
left outer join sys.index_columns IC on I.object_id=IC.object_id and IC.OBJECT_id = T.object_id
and I.index_id=IC.index_id and C.column_id = IC.column_id
left outer join sys.default_constraints as DC on DC.parent_object_id = T.object_id and DC.parent_column_id = C.column_id and DC.type = 'D'
where
T.name = 'TABLENAME'
and S.[name] = 'SCHEMANAME'
order by C.column_id asc;
Give this a look as a SQL Server version of
desc tablename
in MySQLMSSQL data types: https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver16