ALTER TABLE 表名称 ADD 字段名称 numeric(18, 0) NOT NULL IDENTITY (1, 1)
IF object_id('Tempdb..#aa') IS not NULL begin drop table #aa end SELECT IDENTITY (int, 1, 1) AS a, * INTO #aa FROM table endif select * from #aa 这样的话就在临时表#aa中有了新的自动累加字段
恕小弟无能,我对大哥这句 SELECT IDENTITY (int, 1, 1) AS a, * INTO #aa FROM table 还真看不懂
如果你就是在dbgrid显示的时候显示一个自增的字段的话还可以 oncelldraw的事件中 begin if Column.Index = 0 then with DBGrid1.Canvas do begin FillRect(Rect); if DBGrid1.DataSource.DataSet.RecNo <> -1 then TextOut(Rect.Left + 2, Rect.Top + 2, IntToStr(DBGrid1.DataSource.DataSet.RecNo)); end;
字段名称 numeric(18, 0) NOT NULL IDENTITY (1, 1)
SELECT IDENTITY (int, 1, 1) AS a, *
INTO #aa
FROM table
endif
select * from #aa
这样的话就在临时表#aa中有了新的自动累加字段
SELECT IDENTITY (int, 1, 1) AS a, * INTO #aa FROM table
还真看不懂
oncelldraw的事件中
begin
if Column.Index = 0 then
with DBGrid1.Canvas do
begin
FillRect(Rect);
if DBGrid1.DataSource.DataSet.RecNo <> -1 then
TextOut(Rect.Left + 2, Rect.Top + 2, IntToStr(DBGrid1.DataSource.DataSet.RecNo));
end;