select
(case when a.colorder=1 then d.name else '' end) n'表名',
a.colorder n'字段序號',
a.name n'欄位名',
(case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end) n'標識',
(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) n'主鍵',
b.name n'型別',
a.length n'占用位元組數',
columnproperty(a.id,a.name,'precision') as n'長度',
isnull(columnproperty(a.id,a.name,'scale'),0) as n'小數字數',
(case when a.isnullable=1 then '√'else '' end) n'允許空',
isnull(e.text,'') n'預設值',
isnull(g.[value],'') as n'字段說明'
--into ##tx
from syscolumns a left join systypes b
on a.xtype=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 sysproperties g
on a.id=g.id and a.colid = g.**allid
order by object_name(a.id),a.colorder
select
表名=case when a.colorder=1 then d.name else '' end,
字段序號=a.colorder,
欄位名=a.name,
標識=case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end,
主鍵=case when exists(select 1 from sysobjects where xtype='pk' 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,''),
字段說明=isnull(g.[value],'')
from syscolumns a
left join systypes b on a.xtype=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 sysproperties g on a.id=g.id and a.colid=g.**allid
order by a.id,a.colorder
從資料庫中匯出資料
首先開啟xp cmdshell許可權 exec sp configure show advanced options 1 reconfigure exec sp configure xp cmdshell 1 reconfigure 1,匯出資料到txt exec master.xp cmdshel...
從資料庫中匯出 csv檔案
需求 本次將資料庫中的資料匯出成.csv檔案 office可以開啟 資料的生成,根據你所選中的資料進行生成 params activity id 活動的id params form id 匯出資料中選中的活動id public function exportdata activity id,form...
NPOI從資料庫中匯出到Excel
一,如何把資料庫的資料匯入到excel?1 可以使用多種方式,但是較好的一種是使用npoi。2 npoi的缺陷 只能在office2003中使用,office2007無法使用npoi,同時對於wps也不能使用。3 使用是要引入npoi的dll外部檔案,下面的 使用了簡單三層的思想。二,把資料庫中的資...