MS Sql Server匯出表結構

來源:互聯網
上載者:User
SELECT     表名       = Case When A.colorder=1 Then D.name Else '' End,     表說明     = Case When A.colorder=1 Then isnull(F.value,'') Else '' End,     欄位序號   = A.colorder,     欄位名     = A.name,     欄位說明   = isnull(G.[value],''),     標識       = Case When COLUMNPROPERTY( A.id,A.name,'IsIdentity')=1 Then '√'Else '' End,     主鍵       = Case When exists(SELECT 1 FROM sysobjects Where xtype='PK' and parent_obj=A.id and name in (                      SELECT name FROM sysindexes WHERE indid in( SELECT indid FROM sysindexkeys WHERE id = A.id AND colid=A.colid))) then '√' else '' end,     類型       = B.name,     佔用位元組數 = A.Length,     長度       = COLUMNPROPERTY(A.id,A.name,'PRECISION'),     小數位元   = isnull(COLUMNPROPERTY(A.id,A.name,'Scale'),0),     允許空     = Case When A.isnullable=1 Then '√'Else '' End,     預設值     = isnull(E.Text,'') FROM     syscolumns A Left Join     systypes B On     A.xusertype=B.xusertype Inner Join     sysobjects D On     A.id=D.id  and D.xtype='U' and  D.name<>'dtproperties' Left Join     syscomments E on     A.cdefault=E.id Left Join sys.extended_properties  G on     A.id=G.major_id and A.colid=G.minor_id Left Join sys.extended_properties F On     D.id=F.major_id and F.minor_id=0     --where d.name='OrderInfo'    --如果只查詢指定表,加上此條件 Order By     A.id,A.colorder

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.