insert into T_Bus_DemandsType(
      [F_Code],[F_Name]
      ,[F_ParentId]
      ,[F_ParentCode]
      ,[F_layer]
      ,[F_CreateBy]
      ,[F_CreateOn]
      ,[F_IsDelete])
      select [F_Code],[F_Name],[F_ParentId],[F_ParentCode],4,'8000',GETDATE(),0 from A_layer4
      
      
      
--drop table A_layer0
--drop table A_layer1
--drop table A_layer2
--drop table A_layer3
--drop table A_layer4
      
--update T_Bus_DemandsType set f_code=f_parentCode+convert(varchar,F_id)+'|' where f_layer=4
--select [F_Name],[F_ParentId],[F_ParentCode],4,'8000',GETDATE(),0 from AA_layer4
--drop table AA_layer4
      
--update T_Bus_DemandsType set f_code=f_parentCode+convert(varchar,F_id)+'|' where f_layer=3
--select [F_Name],[F_ParentId],[F_ParentCode],3,'8000',GETDATE(),0 from AA_layer3
--drop table AA_layer3

--update T_Bus_DemandsType set f_code=f_parentCode+convert(varchar,F_id)+'|' where f_layer=2
--select [F_Name],[F_ParentId],[F_ParentCode],[F_layer],[F_Sort],'8000',GETDATE(),[F_IsDelete] from AA_layer2
--drop table AA_layer2

--update T_Bus_DemandsType set f_code=f_parentCode+convert(varchar,F_id)+'|' where f_layer=1
--select [F_Code],[F_Name],[F_ParentId],[F_ParentCode],[F_layer],[F_Sort],'8000',GETDATE(),[F_IsDelete] from A_layer1
--drop table AA_layer1

--select [F_Code],[F_Name],[F_ParentId],[F_ParentCode],[F_layer],[F_Sort],'8000',GETDATE(),[F_IsDelete] from A_layer0
--drop table AA_layer0

select * from T_Bus_DemandsType

--delete from T_Bus_DemandsType where f_id in (385,
--386,
--387,
--388,
--389,
--390,
--391)

--update T_Bus_DemandsType set f_code=f_parentCode+convert(varchar,F_id)+'|',f_layer=4 where isnull(f_code,'')=''