IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP taBLE #temp;
DELETE FROM R_007_65_0002_2010_01 WHERE R_007_65_0002_2010_01.A2 = 2010 AND R_007_65_0002_2010_01.A3 = 1;
SELECT identity(int,1,1) Id, R_007_65_0003_2010_01.a1 as A0, +SUM(R_007_65_0003_2010_01.a12) as a12 , 2010 as A2, 01 as A3 , 1 as A4 into #temp FROM R_007_65_0003_2010_01 WHERE (1=1) AND R_007_65_0003_2010_01.A2 = 2010 AND R_007_65_0003_2010_01.A3 = 1 AND 1=1 GROUP BY R_007_65_0003_2010_01.a1 ;
delete #temp where ID not in (select max(Id) from #temp group by A0);
ALTER TABLE #temp DROP COLUMN Id;
INSERT INTO R_007_65_0002_2010_01(A1,A12,A2,A3,A4) select * from #temp;
drop table #temp;IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP taBLE #temp;
DELETE FROM R_007_65_0002_2010_01 WHERE R_007_65_0002_2010_01.A2 = 2010 AND R_007_65_0002_2010_01.A3 = 1;
SELECT identity(int,1,1) Id, R_007_65_0003_2010_02.a1 as A0, +SUM(R_007_65_0003_2010_02.a12) as a12 , 2010 as A2, 01 as A3 , 1 as A4 into #temp FROM R_007_65_0003_2010_02 WHERE (1=1) AND R_007_65_0003_2010_02.A2 = 2010 AND R_007_65_0003_2010_02.A3 = 2 AND 1=1 GROUP BY R_007_65_0003_2010_02.a1 ;
delete #temp where ID not in (select max(Id) from #temp group by A0);
ALTER TABLE #temp DROP COLUMN Id;
INSERT INTO R_007_65_0002_2010_01(A1,A12,A2,A3,A4) select * from #temp;
drop table #temp;如果在中间加个 go
询查分析器中没报错,但在代码中
_command.CommandText = CommandText;
ret = _command.ExecuteNonQuery();
就报错求解!!
DELETE FROM R_007_65_0002_2010_01 WHERE R_007_65_0002_2010_01.A2 = 2010 AND R_007_65_0002_2010_01.A3 = 1;
SELECT identity(int,1,1) Id, R_007_65_0003_2010_01.a1 as A0, +SUM(R_007_65_0003_2010_01.a12) as a12 , 2010 as A2, 01 as A3 , 1 as A4 into #temp FROM R_007_65_0003_2010_01 WHERE (1=1) AND R_007_65_0003_2010_01.A2 = 2010 AND R_007_65_0003_2010_01.A3 = 1 AND 1=1 GROUP BY R_007_65_0003_2010_01.a1 ;
delete #temp where ID not in (select max(Id) from #temp group by A0);
ALTER TABLE #temp DROP COLUMN Id;
INSERT INTO R_007_65_0002_2010_01(A1,A12,A2,A3,A4) select * from #temp;
drop table #temp;IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP taBLE #temp;
DELETE FROM R_007_65_0002_2010_01 WHERE R_007_65_0002_2010_01.A2 = 2010 AND R_007_65_0002_2010_01.A3 = 1;
SELECT identity(int,1,1) Id, R_007_65_0003_2010_02.a1 as A0, +SUM(R_007_65_0003_2010_02.a12) as a12 , 2010 as A2, 01 as A3 , 1 as A4 into #temp FROM R_007_65_0003_2010_02 WHERE (1=1) AND R_007_65_0003_2010_02.A2 = 2010 AND R_007_65_0003_2010_02.A3 = 2 AND 1=1 GROUP BY R_007_65_0003_2010_02.a1 ;
delete #temp where ID not in (select max(Id) from #temp group by A0);
ALTER TABLE #temp DROP COLUMN Id;
INSERT INTO R_007_65_0002_2010_01(A1,A12,A2,A3,A4) select * from #temp;
drop table #temp;如果在中间加个 go
询查分析器中没报错,但在代码中
_command.CommandText = CommandText;
ret = _command.ExecuteNonQuery();
就报错求解!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货