mssql 2005 ,2008匯出資料字典

2021-09-08 08:49:50 字數 1305 閱讀 5937

在你要匯出資料字典的資料空中右鍵,新建查詢,執行如下**即可

select

(case when a.colorder=1 then d.name else '' end)表名,d.xtype as 表型別,

a.colorder 字段序號,

a.name 欄位名,

(case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end) 標識,

(case when (select count(*)

from sysobjects

where (name in

(select name

from sysindexes

where (id = a.id) and (indid in

(select indid

from sysindexkeys

where (id = a.id) and (colid in

(select colid

from syscolumns

where (id = a.id) and (name = a.name))))))) and

(xtype = 'pk'))>0 then '√' else '' end) 主鍵,

b.name 型別,

a.length 占用位元組數,

columnproperty(a.id,a.name,'precision') as 長度,

isnull(columnproperty(a.id,a.name,'scale'),0) as 小數字數,

(case when a.isnullable=1 then '√'else '' end) 允許空,

isnull(e.text,'') 預設值,

isnull(g.[value],'') as 字段說明

from  syscolumns  a left join systypes b

on  a.xtype=b.xusertype

inner join sysobjects d

on a.id=d.id  and  d.xtype in ('u','v') 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.major_id

order by a.id,a.colorder

MSSQL 2005 2008 中的錯誤處理機制

begin try sql endtry begin catch sql 處理出錯動作 endcatch 我們將可能會出錯的sql 寫在begin try.end try 之間,若出錯,剛程式就跳到緊接著的begin try.end try 的beign catch.end catch 中,執行be...

BCP匯入匯出MsSql

匯出資料到tset1.txt,並指定本地資料庫的使用者名稱和密碼 這裡需要指定資料庫完全限定名。username 資料登入名 password 資料庫密碼 exec master.xp cmdshell bcp select from testdb.dbo.testvoucher queryout ...

MSSQL匯入匯出資料

匯出到excel exec master.xp cmdshell bcp settledb.dbo.shanghu out c temp1.xls c q s gnetdata gnetdata u sa p 匯入excel select from opendatasource microsoft....