select * into 臨時表 from 原表
解决方案 »
- SQLServer的注册表项使用技巧六则[原创]
- 怎么样从一个表中删掉与另一个表中字段相同的纪录
- 将数据库CSGO的备份文件CSGOBackUp还原到新建的数据库OJCN,怎么弄
- sql 2000同步问题
- sql2005查询问题 很奇怪
- 问下,sql2000 数据库存储过程中,可以写存储函数吗?怎么写,我baidu,google了,没有找到相应的语法!
- sql动态查询
- 如何卸载sql7.0?
- 2台 sqlserver 如何進行資料同步複製
- sql查询,某字段重复的第一行显示第二开始为空,急救
- ado ,odbc ,oledb 联接数据库的原理和区别
- sql server如何导入foxpro的表?
var
Ds:TAdoDataSet;
i,j:integer;
begin
if (Node=TrVw.Items[0]) or (Node.Parent<>TrVw.Items[0]) then
begin
Grid.RowCount:=2;
Grid.ColCount:=2;
For i:=0 to Grid.ColCount-1 do Grid.Cells[i,0]:='';
For i:=0 to Grid.ColCount-1 do Grid.Cells[i,1]:='';
if (Node<>TrVw.Items[0]) then
begin
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=AdoConn;
Ds.CommandText:=' select'+
' 序号=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],''''),'+
' 索引名称=isnull(h.索引名称,''''),'+
' 索引顺序=isnull(h.排序,'''')'+
' from syscolumns a'+
' left join systypes b on a.xtype=b.xusertype'+
' left join sysobjects d on a.id=d.id and d.xtype=''u'' and d.status>=0'+
' left join syscomments e on a.cdefault=e.id'+
' left join sysproperties g on a.id=g.id and a.colid=g.smallid'+
' left join sysproperties f on d.id=f.id and f.smallid=0'+
' left join('+
' select 索引名称=a.name,c.id,d.colid,排序=case indexkey_property(c.id,b.indid,b.keyno,''isdescending'')when 1 then ''降序'' when 0 then ''升序'' end'+
' from sysindexes a join sysindexkeys b on a.id=b.id and a.indid=b.indid'+
' join (select id,colid,indid=min(indid) from sysindexkeys group by id,colid) b1 on b.id=b1.id and b.colid=b1.colid and b.indid=b1.indid'+
' join sysobjects c on b.id=c.id and c.xtype=''u'' and c.status>=0'+
' join syscolumns d on b.id=d.id and b.colid=d.colid'+
' where a.indid not in(0,255)'+
' ) h on a.id=h.id and a.colid=h.colid'+
' where d.name='''+Node.Parent.Text+''''+
' order by a.id,a.colorder';
DS.CommandTimeout:=0;
Ds.Open;
Grid.RowCount:=2;
Grid.FixedRows:=1;
Grid.FixedCols:=1;
Grid.ColCount:=Ds.FieldDefs.Count;
For i := 0 To Grid.ColCount - 1 do
begin
Grid.Cells[i,0]:=Ds.FieldDefs[i].Name;
Grid.Cells[i,1]:='';
end;
if not Ds.Eof or not Ds.Bof then
begin
Ds.First;
FlatGauge1.MaxValue:=Ds.RecordCount;
FlatGauge1.Progress:=0;
FlatGauge1.Visible:=True;
While Not Ds.EOF do
begin
For i := 0 To Grid.ColCount - 1 do
Grid.Cells[i,Grid.RowCount-1]:=Ds.Fields[i].AsString;
Ds.Next;
FlatGauge1.Progress:=FlatGauge1.Progress+1;
Grid.RowCount:=Grid.RowCount+1;
for i:=0 to Grid.ColCount-1 do
Grid.Cells[i,Grid.RowCount-1]:='';
end;
Grid.RowCount:=Grid.RowCount-1;
end;
finally
Ds.Close;
Ds.Free;
FlatGauge1.Visible:=False;
end;
end;
end
else
begin
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=AdoConn;
try
AdoConn.BeginTrans;
case FindType of
-1:exit;
0,1:AdoConn.Execute('select identity(int,1,1) as id,* into #t from '+Node.Text);
2:begin
if IsText then AdoConn.Execute('select identity(int,1,1) as id,* into #t from '+Node.Text+ ' where isnull('+Field+','''')=''''')
else AdoConn.Execute('select identity(int,1,1) as id,* into #t from '+Node.Text+ ' where isnull('+Field+',0)=0');
end;
3:begin
if IsText then AdoConn.Execute('select identity(int,1,1) as id,* into #t from '+Node.Text+ ' where '+Field+'='''+Value+'''')
else AdoConn.Execute('select identity(int,1,1) as id,* into #t from '+Node.Text+ ' where '+Field+'='+String(Value));
end;
end;
Ds.CommandText:='select * from #t order by id';
DS.CommandTimeout:=0;
Ds.Open;
Grid.RowCount:=2;
Grid.FixedRows:=1;
Grid.FixedCols:=1;
Grid.ColCount:=Ds.FieldDefs.Count;
For i := 0 To Grid.ColCount - 1 do
begin
Grid.Cells[i,0]:=Ds.FieldDefs[i].Name;
Grid.Cells[i,1]:='';
end;
if not Ds.Eof or not Ds.Bof then
begin
Ds.First;
FlatGauge1.MaxValue:=Ds.RecordCount;
FlatGauge1.Progress:=0;
FlatGauge1.Visible:=True;
While Not Ds.EOF do
begin
For i := 0 To Grid.ColCount - 1 do
Grid.Cells[i,Grid.RowCount-1]:=Ds.Fields[i].AsString;
Ds.Next;
FlatGauge1.Progress:=FlatGauge1.Progress+1;
Grid.RowCount:=Grid.RowCount+1;
for i:=0 to Grid.ColCount-1 do
Grid.Cells[i,Grid.RowCount-1]:='';
end;
Grid.RowCount:=Grid.RowCount-1;
end;
AdoConn.Execute('drop table #t');
AdoConn.CommitTrans;
except
AdoConn.RollbackTrans;
raise;
end;
finally
Ds.Close;
Ds.Free;
FlatGauge1.Visible:=False;
end;
end;
AutosetGrid(Grid);
end;自己写的数据精灵中的部分代码,楼主需要留下EMAIL