--取上个月的工资数据记录,导出到表#temp中
select * into #temp from gz_gz where imonth int (select max(month) from gz_gz )
--修改上个月的月份值或年度值
update #temp
set gzmonth=gzmonth+1
or
update #temp
set gzyear=gzyear+1
--导入到工资表中
insert into gz_gz select * from #temp
select * into #temp from gz_gz where imonth int (select max(month) from gz_gz )
--修改上个月的月份值或年度值
update #temp
set gzmonth=gzmonth+1
or
update #temp
set gzyear=gzyear+1
--导入到工资表中
insert into gz_gz select * from #temp
insert into 表 (年,月份,其它字段) select 年字段,max(月份)+1,其它字段 from 表 where
year(getdate()) = 年 and month(getdate()) = max(月份)
select * into #tmptb from tb1 where 年月='2005-1'
select b.fld1,b.fld2,convert(char(7),getdate(),120) into tb1 a from #tmptb b
drop table #tmptb
--注意,b.fld1,b.fld2,是你的表的除了 年月 字段的其它字段列表,注意字段的顺序要对应好了.
可否给出完整的代码?