sql 取得欄位之名稱及其長度
SELECT '@'+c.name + ' ' +
CASE c.system_type_id
WHEN 167 THEN 'VARCHAR('+CAST(c.max_length AS VARCHAR(5))+')'
WHEN 106 THEN 'DECIMAL('+CAST(c.precision AS VARCHAR(5))+','+CAST(c.scale AS VARCHAR(5))+')'
WHEN 108 THEN 'DECIMAL('+CAST(c.precision AS VARCHAR(5))+','+CAST(c.scale AS VARCHAR(5))+')'
WHEN 35 THEN 'TEXT'
WHEN 61 THEN 'DATETIME'
WHEN 231 THEN 'NVARCHAR('+CAST(c.max_length/2 AS VARCHAR(5))+')'
WHEN 36 THEN 'UNIQUEIDENTIFIER'
WHEN 175 THEN 'CHAR('+CAST(c.max_length AS VARCHAR(5))+')'
WHEN 56 THEN 'INT)'
ELSE '' END
,c.name
FROM sys.columns c WHERE c.object_id ='1056058848'
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步