在sql server2000的设计表中
列名 数据类型 长度 允许空
name char 10
old int 4 NULL
...
怎样把他们导到excel中
列名 数据类型 长度 允许空
name char 10
old int 4 NULL
...
答案:
create proc proc_design
as
begin
set nocount on
declare @myid int
declare @name varchar(256)
create table #tmp (tablename varchar(256),colname varchar(256),typename varchar(256),length int,isnullable int)
declare my_cur cursor for select name ,id from sysobjects where type ='U'
open my_cur
fetch next from my_cur into @name,@myid
while @@fetch_status = 0
begin
insert #tmp select @name,a.name ,b.name ,a.length, a.isnullable from syscolumns a, systypes b where a.xtype=b.xtype and a.id =@myid
fetch next from my_cur into @name,@myid
end
close my_cur
deallocate my_cur
select * from #tmp
set nocount off
end