-- 转历史时丢了的订单从备份数据库里插入回db数据库里; -- 关联12张表; -- 步骤:新建数据库back,然后从备份里还原,把以下命令的id='...'单引号内的订单改成要插回db里的订单,再执行。 --1.dindansp表; set IDENTITY_INSERT [db].[dbo].[dindansp] ON insert into [db].[dbo].[dindansp] ([id] ,[spid] ,[shuliang] ,[kind] ,[price] ,[name] ,[no] ,[status1] ,[status2] ,[status3] ,[status4] ,[autoid] ,[date1] ,[date2] ,[date3] ,[date4] ,[name1] ,[name2] ,[name3] ,[name4] ,[hqdate] ,[hqtime] ,[urgent] ,[taketime] ,[no2] ,[status5] ,[status6] ,[date5] ,[date6] ,[name5] ,[name6] ,[growthtxname] ,[ps] ,[zs] ,[ren1] ,[ren2] ,[hqstatus] ,[bz]) select * from [back].[dbo].[dindansp] where id='111111' SET IDENTITY_INSERT [db].[dbo].[dindansp] OFF --2.dindanbukuan表; set IDENTITY_INSERT [db].[dbo].[dindanbukuan] ON insert into [db].[dbo].[dindanbukuan] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck] from [back].[dbo].[dindanbukuan] where id='111111' SET IDENTITY_INSERT [db].[dbo].[dindanbukuan] OFF --3.dindanbukuan2表; set IDENTITY_INSERT [db].[dbo].[dindanbukuan2] ON insert into [db].[dbo].[dindanbukuan2] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2] from [back].[dbo].[dindanbukuan2] where id='111111' SET IDENTITY_INSERT [db].[dbo].[dindanbukuan2] OFF --4.dindan表; insert into [db].[dbo].[dindan] select * from [back].[dbo].[dindan] where id='111111' --5.photoprint表; insert into [db].[dbo].[photoprint] select * from [back].[dbo].[photoprint] where id='111111' --6.client表; insert into [db].[dbo].[client] select * from [back].[dbo].[client] where id='111111' --7.burncdreg表; insert into [db].[dbo].[burncdreg] select * from [back].[dbo].[burncdreg] where id='111111' --8.digitalwork表; insert into [db].[dbo].[digitalwork] select * from [back].[dbo].[digitalwork] where id='111111' --9.mywork; insert into [db].[dbo].[mywork] select * from [back].[dbo].[mywork] where id='111111' --10.dindanjd表; insert into [db].[dbo].[dindanjd] select * from [back].[dbo].[dindanjd] where id='111111' --11.dindansp2表; insert into [db].[dbo].[dindansp2] select * from [back].[dbo].[dindansp2] where id='111111' --12.dindansp3表; insert into [db].[dbo].[dindansp3] select * from [back].[dbo].[dindansp3] where id='111111'