--0.���ݵ�ǰdb��dindanjd����dindanjd_back��;
select * into [db].[dbo].[dindanjd_back] from [db].[dbo].[dindanjd]
go

--1.��2014��db��dindanjd��ȫ����¼���뵽#tempall����;
select * into #tempall from [db].[dbo].[dindanjd]
insert into #tempall select * from [2014].[dbo].[dindanjd]
go

--2.���˵���ȫ�ظ��ļ�¼;
select distinct * into #tempdis from #tempall
go

drop table #tempall
go

--3.��ȡָ���ֶεIJ��ظ���¼,���˵�����ȫ�ظ��ļ�¼;
select identity(int,1,1) as autoid, * into #temp1 from #tempdis
select min(autoid) as autoid into #temp2 from #temp1 group by id,name
select [id],[name],[date],[time],[waiter1],[waiter2],[status],[waiter12],[waiter22],[bookingdate],[dress],[bz],[clerk],[inputtime],[branch]
into [db].[dbo].[dindanjd#] from #temp1 where autoid in(select autoid from #temp2) order by id
go

--4.�����˺õļ�¼���²���ԭ��;
drop table #tempdis
drop table #temp1
drop table #temp2
truncate table [db].[dbo].[dindanjd]
go

insert into [db].[dbo].[dindanjd] select * from [db].[dbo].[dindanjd#]
go

drop table [db].[dbo].[dindanjd#]
go
--5.����;