declare @targested_table_name nvarchar(500);
declare @table_id int;
declare @new_table_name nvarchar(500)
declare @nunmber_rows_in_excel int
set @targested_table_name='pgim_product'
set @new_table_name='[PRODUCT_SETUP].[PRODUCT_SETUP_MASTER]'
set @table_id=2
SELECT @nunmber_rows_in_excel=
( (CASE WHEN col_01 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_02 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_03 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_04 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_05 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_06 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_07 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_08 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_09 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_10 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_11 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_12 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_13 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_14 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_15 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_16 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_17 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_18 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_19 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_20 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_21 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_22 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_23 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_24 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_25 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_26 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_27 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_28 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_29 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_30 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_31 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_32 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_33 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_34 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_35 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_36 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_37 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_38 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_39 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_40 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_41 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_42 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_43 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_44 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_45 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_46 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_47 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_48 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_49 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_50 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_51 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_52 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_53 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_54 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_55 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_56 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_57 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_58 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_59 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_60 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_61 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_62 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_63 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_64 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_65 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_66 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_67 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_68 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_69 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_70 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_71 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_72 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_73 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_74 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_75 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_76 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_77 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_78 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_79 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_80 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_81 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_82 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_83 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_84 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_85 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_86 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_87 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_88 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_89 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_90 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_91 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_92 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_93 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_94 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_95 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_96 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_97 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_98 IS NULL THEN 0 ELSE 1 END)
+ (CASE WHEN col_99 IS NULL THEN 0 ELSE 1 END)
)
FROM oracle_cba_database.[dbo].[CBA_TABLES]
WHERE TABLE_NAME=@targested_table_name
create table #Excel_data
(COL_01 Nvarchar(100))
declare @column_creator int;
set @column_creator=2
declare @new_column_name nvarchar(50);
while(@column_creator<=@nunmber_rows_in_excel)
begin
set @new_column_name=case when @column_creator<10 then 'COL_0'+convert(nvarchar,@column_creator) else 'COL_'+convert(nvarchar,@column_creator) end
declare @DynamicSQL nvarchar(max)
SET @DynamicSQL = 'ALTER TABLE #Excel_data ADD ['+ @new_column_name +'] NVARCHAR(1000)'
EXEC(@DynamicSQL)
set @column_creator=@column_creator+1
end
--BULK INSERT #Excel_data
--FROM 'C:\Users\sawan\Desktop\CBA_MIG\CBA_MIG.csv'
--WITH
--( FIRSTROW = 2,
-- FIELDTERMINATOR = ',',
-- ROWTERMINATOR = '\n',
-- TABLOCK
--)
select * from #Excel_data
insert into #Excel_data
select * from
oracle_cba_database.[mst].[pgim_product]
select * from #Excel_data
declare @new_table_colum_list nvarchar(max)
declare @old_table_colum_list nvarchar(max)
declare @New_colum_count int
select @new_table_colum_list=
( (CASE WHEN col_01 IS NULL THEN '' ELSE concat(LEFT(col_01, CHARINDEX('$', col_01) -1),',') END)
+ (CASE WHEN col_02 IS NULL THEN '' ELSE concat(LEFT(col_02, CHARINDEX('$', col_02) -1),',') END)
+ (CASE WHEN col_03 IS NULL THEN '' ELSE concat(LEFT(col_03, CHARINDEX('$', col_03) -1),',') END)
+ (CASE WHEN col_04 IS NULL THEN '' ELSE concat(LEFT(col_04, CHARINDEX('$', col_04) -1),',') END)
+ (CASE WHEN col_05 IS NULL THEN '' ELSE concat(LEFT(col_05, CHARINDEX('$', col_05) -1),',') END)
+ (CASE WHEN col_06 IS NULL THEN '' ELSE concat(LEFT(col_06, CHARINDEX('$', col_06) -1),',') END)
+ (CASE WHEN col_07 IS NULL THEN '' ELSE concat(LEFT(col_07, CHARINDEX('$', col_07) -1),',') END)
+ (CASE WHEN col_08 IS NULL THEN '' ELSE concat(LEFT(col_08, CHARINDEX('$', col_08) -1),',') END)
+ (CASE WHEN col_09 IS NULL THEN '' ELSE concat(LEFT(col_09, CHARINDEX('$', col_09) -1),',') END)
+ (CASE WHEN col_10 IS NULL THEN '' ELSE concat(LEFT(col_10, CHARINDEX('$', col_10) -1),',') END)
+ (CASE WHEN col_11 IS NULL THEN '' ELSE concat(LEFT(col_11, CHARINDEX('$', col_11) -1),',') END)
+ (CASE WHEN col_12 IS NULL THEN '' ELSE concat(LEFT(col_12, CHARINDEX('$', col_12) -1),',') END)
+ (CASE WHEN col_13 IS NULL THEN '' ELSE concat(LEFT(col_13, CHARINDEX('$', col_13) -1),',') END)
+ (CASE WHEN col_14 IS NULL THEN '' ELSE concat(LEFT(col_14, CHARINDEX('$', col_14) -1),',') END)
+ (CASE WHEN col_15 IS NULL THEN '' ELSE concat(LEFT(col_15, CHARINDEX('$', col_15) -1),',') END)
+ (CASE WHEN col_16 IS NULL THEN '' ELSE concat(LEFT(col_16, CHARINDEX('$', col_16) -1),',') END)
+ (CASE WHEN col_17 IS NULL THEN '' ELSE concat(LEFT(col_17, CHARINDEX('$', col_17) -1),',') END)
+ (CASE WHEN col_18 IS NULL THEN '' ELSE concat(LEFT(col_18, CHARINDEX('$', col_18) -1),',') END)
+ (CASE WHEN col_19 IS NULL THEN '' ELSE concat(LEFT(col_19, CHARINDEX('$', col_19) -1),',') END)
+ (CASE WHEN col_20 IS NULL THEN '' ELSE concat(LEFT(col_20, CHARINDEX('$', col_20) -1),',') END)
+ (CASE WHEN col_21 IS NULL THEN '' ELSE concat(LEFT(col_21, CHARINDEX('$', col_21) -1),',') END)
+ (CASE WHEN col_22 IS NULL THEN '' ELSE concat(LEFT(col_22, CHARINDEX('$', col_22) -1),',') END)
+ (CASE WHEN col_23 IS NULL THEN '' ELSE concat(LEFT(col_23, CHARINDEX('$', col_23) -1),',') END)
+ (CASE WHEN col_24 IS NULL THEN '' ELSE concat(LEFT(col_24, CHARINDEX('$', col_24) -1),',') END)
+ (CASE WHEN col_25 IS NULL THEN '' ELSE concat(LEFT(col_25, CHARINDEX('$', col_25) -1),',') END)
+ (CASE WHEN col_26 IS NULL THEN '' ELSE concat(LEFT(col_26, CHARINDEX('$', col_26) -1),',') END)
+ (CASE WHEN col_27 IS NULL THEN '' ELSE concat(LEFT(col_27, CHARINDEX('$', col_27) -1),',') END)
+ (CASE WHEN col_28 IS NULL THEN '' ELSE concat(LEFT(col_28, CHARINDEX('$', col_28) -1),',') END)
+ (CASE WHEN col_29 IS NULL THEN '' ELSE concat(LEFT(col_29, CHARINDEX('$', col_29) -1),',') END)
+ (CASE WHEN col_30 IS NULL THEN '' ELSE concat(LEFT(col_30, CHARINDEX('$', col_30) -1),',') END)
+ (CASE WHEN col_31 IS NULL THEN '' ELSE concat(LEFT(col_31, CHARINDEX('$', col_31) -1),',') END)
+ (CASE WHEN col_32 IS NULL THEN '' ELSE concat(LEFT(col_32, CHARINDEX('$', col_32) -1),',') END)
+ (CASE WHEN col_33 IS NULL THEN '' ELSE concat(LEFT(col_33, CHARINDEX('$', col_33) -1),',') END)
+ (CASE WHEN col_34 IS NULL THEN '' ELSE concat(LEFT(col_34, CHARINDEX('$', col_34) -1),',') END)
+ (CASE WHEN col_35 IS NULL THEN '' ELSE concat(LEFT(col_35, CHARINDEX('$', col_35) -1),',') END)
+ (CASE WHEN col_36 IS NULL THEN '' ELSE concat(LEFT(col_36, CHARINDEX('$', col_36) -1),',') END)
+ (CASE WHEN col_37 IS NULL THEN '' ELSE concat(LEFT(col_37, CHARINDEX('$', col_37) -1),',') END)
+ (CASE WHEN col_38 IS NULL THEN '' ELSE concat(LEFT(col_38, CHARINDEX('$', col_38) -1),',') END)
+ (CASE WHEN col_39 IS NULL THEN '' ELSE concat(LEFT(col_39, CHARINDEX('$', col_39) -1),',') END)
+ (CASE WHEN col_40 IS NULL THEN '' ELSE concat(LEFT(col_40, CHARINDEX('$', col_40) -1),',') END)
+ (CASE WHEN col_41 IS NULL THEN '' ELSE concat(LEFT(col_41, CHARINDEX('$', col_41) -1),',') END)
+ (CASE WHEN col_42 IS NULL THEN '' ELSE concat(LEFT(col_42, CHARINDEX('$', col_42) -1),',') END)
+ (CASE WHEN col_43 IS NULL THEN '' ELSE concat(LEFT(col_43, CHARINDEX('$', col_43) -1),',') END)
+ (CASE WHEN col_44 IS NULL THEN '' ELSE concat(LEFT(col_44, CHARINDEX('$', col_44) -1),',') END)
+ (CASE WHEN col_45 IS NULL THEN '' ELSE concat(LEFT(col_45, CHARINDEX('$', col_45) -1),',') END)
+ (CASE WHEN col_46 IS NULL THEN '' ELSE concat(LEFT(col_46, CHARINDEX('$', col_46) -1),',') END)
+ (CASE WHEN col_47 IS NULL THEN '' ELSE concat(LEFT(col_47, CHARINDEX('$', col_47) -1),',') END)
+ (CASE WHEN col_48 IS NULL THEN '' ELSE concat(LEFT(col_48, CHARINDEX('$', col_48) -1),',') END)
+ (CASE WHEN col_49 IS NULL THEN '' ELSE concat(LEFT(col_49, CHARINDEX('$', col_49) -1),',') END)
+ (CASE WHEN col_50 IS NULL THEN '' ELSE concat(LEFT(col_50, CHARINDEX('$', col_50) -1),',') END)
+ (CASE WHEN col_51 IS NULL THEN '' ELSE concat(LEFT(col_51, CHARINDEX('$', col_51) -1),',') END)
+ (CASE WHEN col_52 IS NULL THEN '' ELSE concat(LEFT(col_52, CHARINDEX('$', col_52) -1),',') END)
+ (CASE WHEN col_53 IS NULL THEN '' ELSE concat(LEFT(col_53, CHARINDEX('$', col_53) -1),',') END)
+ (CASE WHEN col_54 IS NULL THEN '' ELSE concat(LEFT(col_54, CHARINDEX('$', col_54) -1),',') END)
+ (CASE WHEN col_55 IS NULL THEN '' ELSE concat(LEFT(col_55, CHARINDEX('$', col_55) -1),',') END)
+ (CASE WHEN col_56 IS NULL THEN '' ELSE concat(LEFT(col_56, CHARINDEX('$', col_56) -1),',') END)
+ (CASE WHEN col_57 IS NULL THEN '' ELSE concat(LEFT(col_57, CHARINDEX('$', col_57) -1),',') END)
+ (CASE WHEN col_58 IS NULL THEN '' ELSE concat(LEFT(col_58, CHARINDEX('$', col_58) -1),',') END)
+ (CASE WHEN col_59 IS NULL THEN '' ELSE concat(LEFT(col_59, CHARINDEX('$', col_59) -1),',') END)
+ (CASE WHEN col_60 IS NULL THEN '' ELSE concat(LEFT(col_60, CHARINDEX('$', col_60) -1),',') END)
+ (CASE WHEN col_61 IS NULL THEN '' ELSE concat(LEFT(col_61, CHARINDEX('$', col_61) -1),',') END)
+ (CASE WHEN col_62 IS NULL THEN '' ELSE concat(LEFT(col_62, CHARINDEX('$', col_62) -1),',') END)
+ (CASE WHEN col_63 IS NULL THEN '' ELSE concat(LEFT(col_63, CHARINDEX('$', col_63) -1),',') END)
+ (CASE WHEN col_64 IS NULL THEN '' ELSE concat(LEFT(col_64, CHARINDEX('$', col_64) -1),',') END)
+ (CASE WHEN col_65 IS NULL THEN '' ELSE concat(LEFT(col_65, CHARINDEX('$', col_65) -1),',') END)
+ (CASE WHEN col_66 IS NULL THEN '' ELSE concat(LEFT(col_66, CHARINDEX('$', col_66) -1),',') END)
+ (CASE WHEN col_67 IS NULL THEN '' ELSE concat(LEFT(col_67, CHARINDEX('$', col_67) -1),',') END)
+ (CASE WHEN col_68 IS NULL THEN '' ELSE concat(LEFT(col_68, CHARINDEX('$', col_68) -1),',') END)
+ (CASE WHEN col_69 IS NULL THEN '' ELSE concat(LEFT(col_69, CHARINDEX('$', col_69) -1),',') END)
+ (CASE WHEN col_70 IS NULL THEN '' ELSE concat(LEFT(col_70, CHARINDEX('$', col_70) -1),',') END)
+ (CASE WHEN col_71 IS NULL THEN '' ELSE concat(LEFT(col_71, CHARINDEX('$', col_71) -1),',') END)
+ (CASE WHEN col_72 IS NULL THEN '' ELSE concat(LEFT(col_72, CHARINDEX('$', col_72) -1),',') END)
+ (CASE WHEN col_73 IS NULL THEN '' ELSE concat(LEFT(col_73, CHARINDEX('$', col_73) -1),',') END)
+ (CASE WHEN col_74 IS NULL THEN '' ELSE concat(LEFT(col_74, CHARINDEX('$', col_74) -1),',') END)
+ (CASE WHEN col_75 IS NULL THEN '' ELSE concat(LEFT(col_75, CHARINDEX('$', col_75) -1),',') END)
+ (CASE WHEN col_76 IS NULL THEN '' ELSE concat(LEFT(col_76, CHARINDEX('$', col_76) -1),',') END)
+ (CASE WHEN col_77 IS NULL THEN '' ELSE concat(LEFT(col_77, CHARINDEX('$', col_77) -1),',') END)
+ (CASE WHEN col_78 IS NULL THEN '' ELSE concat(LEFT(col_78, CHARINDEX('$', col_78) -1),',') END)
+ (CASE WHEN col_79 IS NULL THEN '' ELSE concat(LEFT(col_79, CHARINDEX('$', col_79) -1),',') END)
+ (CASE WHEN col_80 IS NULL THEN '' ELSE concat(LEFT(col_80, CHARINDEX('$', col_80) -1),',') END)
+ (CASE WHEN col_81 IS NULL THEN '' ELSE concat(LEFT(col_81, CHARINDEX('$', col_81) -1),',') END)
+ (CASE WHEN col_82 IS NULL THEN '' ELSE concat(LEFT(col_82, CHARINDEX('$', col_82) -1),',') END)
+ (CASE WHEN col_83 IS NULL THEN '' ELSE concat(LEFT(col_83, CHARINDEX('$', col_83) -1),',') END)
+ (CASE WHEN col_84 IS NULL THEN '' ELSE concat(LEFT(col_84, CHARINDEX('$', col_84) -1),',') END)
+ (CASE WHEN col_85 IS NULL THEN '' ELSE concat(LEFT(col_85, CHARINDEX('$', col_85) -1),',') END)
+ (CASE WHEN col_86 IS NULL THEN '' ELSE concat(LEFT(col_86, CHARINDEX('$', col_86) -1),',') END)
+ (CASE WHEN col_87 IS NULL THEN '' ELSE concat(LEFT(col_87, CHARINDEX('$', col_87) -1),',') END)
+ (CASE WHEN col_88 IS NULL THEN '' ELSE concat(LEFT(col_88, CHARINDEX('$', col_88) -1),',') END)
+ (CASE WHEN col_89 IS NULL THEN '' ELSE concat(LEFT(col_89, CHARINDEX('$', col_89) -1),',') END)
+ (CASE WHEN col_90 IS NULL THEN '' ELSE concat(LEFT(col_90, CHARINDEX('$', col_90) -1),',') END)
+ (CASE WHEN col_91 IS NULL THEN '' ELSE concat(LEFT(col_91, CHARINDEX('$', col_91) -1),',') END)
+ (CASE WHEN col_92 IS NULL THEN '' ELSE concat(LEFT(col_92, CHARINDEX('$', col_92) -1),',') END)
+ (CASE WHEN col_93 IS NULL THEN '' ELSE concat(LEFT(col_93, CHARINDEX('$', col_93) -1),',') END)
+ (CASE WHEN col_94 IS NULL THEN '' ELSE concat(LEFT(col_94, CHARINDEX('$', col_94) -1),',') END)
+ (CASE WHEN col_95 IS NULL THEN '' ELSE concat(LEFT(col_95, CHARINDEX('$', col_95) -1),',') END)
+ (CASE WHEN col_96 IS NULL THEN '' ELSE concat(LEFT(col_96, CHARINDEX('$', col_96) -1),',') END)
+ (CASE WHEN col_97 IS NULL THEN '' ELSE concat(LEFT(col_97, CHARINDEX('$', col_97) -1),',') END)
+ (CASE WHEN col_98 IS NULL THEN '' ELSE concat(LEFT(col_98, CHARINDEX('$', col_98) -1),',') END)
+ (CASE WHEN col_99 IS NULL THEN '' ELSE concat(LEFT(col_99, CHARINDEX('$', col_99) -1),',') END))
from oracle_cba_database.[dbo].[CBA_TABLES_TANG] where id=@table_id
print(@new_table_colum_list)
select @old_table_colum_list=
( (CASE WHEN COL_01 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_01,LEN(LEFT(COL_01, CHARINDEX('$', COL_01)+ 1)),LEN(COL_01)),',') END)
+ (CASE WHEN COL_02 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_02,LEN(LEFT(COL_02, CHARINDEX('$', COL_02)+ 1)),LEN(COL_02)),',') END)
+ (CASE WHEN COL_03 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_03,LEN(LEFT(COL_03, CHARINDEX('$', COL_03)+ 1)),LEN(COL_03)),',') END)
+ (CASE WHEN COL_04 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_04,LEN(LEFT(COL_04, CHARINDEX('$', COL_04)+ 1)),LEN(COL_04)),',') END)
+ (CASE WHEN COL_05 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_05,LEN(LEFT(COL_05, CHARINDEX('$', COL_05)+ 1)),LEN(COL_05)),',') END)
+ (CASE WHEN COL_06 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_06,LEN(LEFT(COL_06, CHARINDEX('$', COL_06)+ 1)),LEN(COL_06)),',') END)
+ (CASE WHEN COL_07 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_07,LEN(LEFT(COL_07, CHARINDEX('$', COL_07)+ 1)),LEN(COL_07)),',') END)
+ (CASE WHEN COL_08 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_08,LEN(LEFT(COL_08, CHARINDEX('$', COL_08)+ 1)),LEN(COL_08)),',') END)
+ (CASE WHEN COL_09 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_09,LEN(LEFT(COL_09, CHARINDEX('$', COL_09)+ 1)),LEN(COL_09)),',') END)
+ (CASE WHEN COL_10 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_10,LEN(LEFT(COL_10, CHARINDEX('$', COL_10)+ 1)),LEN(COL_10)),',') END)
+ (CASE WHEN COL_11 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_11,LEN(LEFT(COL_11, CHARINDEX('$', COL_11)+ 1)),LEN(COL_11)),',') END)
+ (CASE WHEN COL_12 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_12,LEN(LEFT(COL_12, CHARINDEX('$', COL_12)+ 1)),LEN(COL_12)),',') END)
+ (CASE WHEN COL_13 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_13,LEN(LEFT(COL_13, CHARINDEX('$', COL_13)+ 1)),LEN(COL_13)),',') END)
+ (CASE WHEN COL_14 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_14,LEN(LEFT(COL_14, CHARINDEX('$', COL_14)+ 1)),LEN(COL_14)),',') END)
+ (CASE WHEN COL_15 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_15,LEN(LEFT(COL_15, CHARINDEX('$', COL_15)+ 1)),LEN(COL_15)),',') END)
+ (CASE WHEN COL_16 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_16,LEN(LEFT(COL_16, CHARINDEX('$', COL_16)+ 1)),LEN(COL_16)),',') END)
+ (CASE WHEN COL_17 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_17,LEN(LEFT(COL_17, CHARINDEX('$', COL_17)+ 1)),LEN(COL_17)),',') END)
+ (CASE WHEN COL_18 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_18,LEN(LEFT(COL_18, CHARINDEX('$', COL_18)+ 1)),LEN(COL_18)),',') END)
+ (CASE WHEN COL_19 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_19,LEN(LEFT(COL_19, CHARINDEX('$', COL_19)+ 1)),LEN(COL_19)),',') END)
+ (CASE WHEN COL_20 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_20,LEN(LEFT(COL_20, CHARINDEX('$', COL_20)+ 1)),LEN(COL_20)),',') END)
+ (CASE WHEN COL_21 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_21,LEN(LEFT(COL_21, CHARINDEX('$', COL_21)+ 1)),LEN(COL_21)),',') END)
+ (CASE WHEN COL_22 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_22,LEN(LEFT(COL_22, CHARINDEX('$', COL_22)+ 1)),LEN(COL_22)),',') END)
+ (CASE WHEN COL_23 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_23,LEN(LEFT(COL_23, CHARINDEX('$', COL_23)+ 1)),LEN(COL_23)),',') END)
+ (CASE WHEN COL_24 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_24,LEN(LEFT(COL_24, CHARINDEX('$', COL_24)+ 1)),LEN(COL_24)),',') END)
+ (CASE WHEN COL_25 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_25,LEN(LEFT(COL_25, CHARINDEX('$', COL_25)+ 1)),LEN(COL_25)),',') END)
+ (CASE WHEN COL_26 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_26,LEN(LEFT(COL_26, CHARINDEX('$', COL_26)+ 1)),LEN(COL_26)),',') END)
+ (CASE WHEN COL_27 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_27,LEN(LEFT(COL_27, CHARINDEX('$', COL_27)+ 1)),LEN(COL_27)),',') END)
+ (CASE WHEN COL_28 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_28,LEN(LEFT(COL_28, CHARINDEX('$', COL_28)+ 1)),LEN(COL_28)),',') END)
+ (CASE WHEN COL_29 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_29,LEN(LEFT(COL_29, CHARINDEX('$', COL_29)+ 1)),LEN(COL_29)),',') END)
+ (CASE WHEN COL_30 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_30,LEN(LEFT(COL_30, CHARINDEX('$', COL_30)+ 1)),LEN(COL_30)),',') END)
+ (CASE WHEN COL_31 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_31,LEN(LEFT(COL_31, CHARINDEX('$', COL_31)+ 1)),LEN(COL_31)),',') END)
+ (CASE WHEN COL_32 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_32,LEN(LEFT(COL_32, CHARINDEX('$', COL_32)+ 1)),LEN(COL_32)),',') END)
+ (CASE WHEN COL_33 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_33,LEN(LEFT(COL_33, CHARINDEX('$', COL_33)+ 1)),LEN(COL_33)),',') END)
+ (CASE WHEN COL_34 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_34,LEN(LEFT(COL_34, CHARINDEX('$', COL_34)+ 1)),LEN(COL_34)),',') END)
+ (CASE WHEN COL_35 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_35,LEN(LEFT(COL_35, CHARINDEX('$', COL_35)+ 1)),LEN(COL_35)),',') END)
+ (CASE WHEN COL_36 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_36,LEN(LEFT(COL_36, CHARINDEX('$', COL_36)+ 1)),LEN(COL_36)),',') END)
+ (CASE WHEN COL_37 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_37,LEN(LEFT(COL_37, CHARINDEX('$', COL_37)+ 1)),LEN(COL_37)),',') END)
+ (CASE WHEN COL_38 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_38,LEN(LEFT(COL_38, CHARINDEX('$', COL_38)+ 1)),LEN(COL_38)),',') END)
+ (CASE WHEN COL_39 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_39,LEN(LEFT(COL_39, CHARINDEX('$', COL_39)+ 1)),LEN(COL_39)),',') END)
+ (CASE WHEN COL_40 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_40,LEN(LEFT(COL_40, CHARINDEX('$', COL_40)+ 1)),LEN(COL_40)),',') END)
+ (CASE WHEN COL_41 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_41,LEN(LEFT(COL_41, CHARINDEX('$', COL_41)+ 1)),LEN(COL_41)),',') END)
+ (CASE WHEN COL_42 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_42,LEN(LEFT(COL_42, CHARINDEX('$', COL_42)+ 1)),LEN(COL_42)),',') END)
+ (CASE WHEN COL_43 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_43,LEN(LEFT(COL_43, CHARINDEX('$', COL_43)+ 1)),LEN(COL_43)),',') END)
+ (CASE WHEN COL_44 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_44,LEN(LEFT(COL_44, CHARINDEX('$', COL_44)+ 1)),LEN(COL_44)),',') END)
+ (CASE WHEN COL_45 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_45,LEN(LEFT(COL_45, CHARINDEX('$', COL_45)+ 1)),LEN(COL_45)),',') END)
+ (CASE WHEN COL_46 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_46,LEN(LEFT(COL_46, CHARINDEX('$', COL_46)+ 1)),LEN(COL_46)),',') END)
+ (CASE WHEN COL_47 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_47,LEN(LEFT(COL_47, CHARINDEX('$', COL_47)+ 1)),LEN(COL_47)),',') END)
+ (CASE WHEN COL_48 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_48,LEN(LEFT(COL_48, CHARINDEX('$', COL_48)+ 1)),LEN(COL_48)),',') END)
+ (CASE WHEN COL_49 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_49,LEN(LEFT(COL_49, CHARINDEX('$', COL_49)+ 1)),LEN(COL_49)),',') END)
+ (CASE WHEN COL_50 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_50,LEN(LEFT(COL_50, CHARINDEX('$', COL_50)+ 1)),LEN(COL_50)),',') END)
+ (CASE WHEN COL_51 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_51,LEN(LEFT(COL_51, CHARINDEX('$', COL_51)+ 1)),LEN(COL_51)),',') END)
+ (CASE WHEN COL_52 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_52,LEN(LEFT(COL_52, CHARINDEX('$', COL_52)+ 1)),LEN(COL_52)),',') END)
+ (CASE WHEN COL_53 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_53,LEN(LEFT(COL_53, CHARINDEX('$', COL_53)+ 1)),LEN(COL_53)),',') END)
+ (CASE WHEN COL_54 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_54,LEN(LEFT(COL_54, CHARINDEX('$', COL_54)+ 1)),LEN(COL_54)),',') END)
+ (CASE WHEN COL_55 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_55,LEN(LEFT(COL_55, CHARINDEX('$', COL_55)+ 1)),LEN(COL_55)),',') END)
+ (CASE WHEN COL_56 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_56,LEN(LEFT(COL_56, CHARINDEX('$', COL_56)+ 1)),LEN(COL_56)),',') END)
+ (CASE WHEN COL_57 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_57,LEN(LEFT(COL_57, CHARINDEX('$', COL_57)+ 1)),LEN(COL_57)),',') END)
+ (CASE WHEN COL_58 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_58,LEN(LEFT(COL_58, CHARINDEX('$', COL_58)+ 1)),LEN(COL_58)),',') END)
+ (CASE WHEN COL_59 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_59,LEN(LEFT(COL_59, CHARINDEX('$', COL_59)+ 1)),LEN(COL_59)),',') END)
+ (CASE WHEN COL_60 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_60,LEN(LEFT(COL_60, CHARINDEX('$', COL_60)+ 1)),LEN(COL_60)),',') END)
+ (CASE WHEN COL_61 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_61,LEN(LEFT(COL_61, CHARINDEX('$', COL_61)+ 1)),LEN(COL_61)),',') END)
+ (CASE WHEN COL_62 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_62,LEN(LEFT(COL_62, CHARINDEX('$', COL_62)+ 1)),LEN(COL_62)),',') END)
+ (CASE WHEN COL_63 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_63,LEN(LEFT(COL_63, CHARINDEX('$', COL_63)+ 1)),LEN(COL_63)),',') END)
+ (CASE WHEN COL_64 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_64,LEN(LEFT(COL_64, CHARINDEX('$', COL_64)+ 1)),LEN(COL_64)),',') END)
+ (CASE WHEN COL_65 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_65,LEN(LEFT(COL_65, CHARINDEX('$', COL_65)+ 1)),LEN(COL_65)),',') END)
+ (CASE WHEN COL_66 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_66,LEN(LEFT(COL_66, CHARINDEX('$', COL_66)+ 1)),LEN(COL_66)),',') END)
+ (CASE WHEN COL_67 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_67,LEN(LEFT(COL_67, CHARINDEX('$', COL_67)+ 1)),LEN(COL_67)),',') END)
+ (CASE WHEN COL_68 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_68,LEN(LEFT(COL_68, CHARINDEX('$', COL_68)+ 1)),LEN(COL_68)),',') END)
+ (CASE WHEN COL_69 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_69,LEN(LEFT(COL_69, CHARINDEX('$', COL_69)+ 1)),LEN(COL_69)),',') END)
+ (CASE WHEN COL_70 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_70,LEN(LEFT(COL_70, CHARINDEX('$', COL_70)+ 1)),LEN(COL_70)),',') END)
+ (CASE WHEN COL_71 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_71,LEN(LEFT(COL_71, CHARINDEX('$', COL_71)+ 1)),LEN(COL_71)),',') END)
+ (CASE WHEN COL_72 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_72,LEN(LEFT(COL_72, CHARINDEX('$', COL_72)+ 1)),LEN(COL_72)),',') END)
+ (CASE WHEN COL_73 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_73,LEN(LEFT(COL_73, CHARINDEX('$', COL_73)+ 1)),LEN(COL_73)),',') END)
+ (CASE WHEN COL_74 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_74,LEN(LEFT(COL_74, CHARINDEX('$', COL_74)+ 1)),LEN(COL_74)),',') END)
+ (CASE WHEN COL_75 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_75,LEN(LEFT(COL_75, CHARINDEX('$', COL_75)+ 1)),LEN(COL_75)),',') END)
+ (CASE WHEN COL_76 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_76,LEN(LEFT(COL_76, CHARINDEX('$', COL_76)+ 1)),LEN(COL_76)),',') END)
+ (CASE WHEN COL_77 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_77,LEN(LEFT(COL_77, CHARINDEX('$', COL_77)+ 1)),LEN(COL_77)),',') END)
+ (CASE WHEN COL_78 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_78,LEN(LEFT(COL_78, CHARINDEX('$', COL_78)+ 1)),LEN(COL_78)),',') END)
+ (CASE WHEN COL_79 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_79,LEN(LEFT(COL_79, CHARINDEX('$', COL_79)+ 1)),LEN(COL_79)),',') END)
+ (CASE WHEN COL_80 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_80,LEN(LEFT(COL_80, CHARINDEX('$', COL_80)+ 1)),LEN(COL_80)),',') END)
+ (CASE WHEN COL_81 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_81,LEN(LEFT(COL_81, CHARINDEX('$', COL_81)+ 1)),LEN(COL_81)),',') END)
+ (CASE WHEN COL_82 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_82,LEN(LEFT(COL_82, CHARINDEX('$', COL_82)+ 1)),LEN(COL_82)),',') END)
+ (CASE WHEN COL_83 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_83,LEN(LEFT(COL_83, CHARINDEX('$', COL_83)+ 1)),LEN(COL_83)),',') END)
+ (CASE WHEN COL_84 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_84,LEN(LEFT(COL_84, CHARINDEX('$', COL_84)+ 1)),LEN(COL_84)),',') END)
+ (CASE WHEN COL_85 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_85,LEN(LEFT(COL_85, CHARINDEX('$', COL_85)+ 1)),LEN(COL_85)),',') END)
+ (CASE WHEN COL_86 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_86,LEN(LEFT(COL_86, CHARINDEX('$', COL_86)+ 1)),LEN(COL_86)),',') END)
+ (CASE WHEN COL_87 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_87,LEN(LEFT(COL_87, CHARINDEX('$', COL_87)+ 1)),LEN(COL_87)),',') END)
+ (CASE WHEN COL_88 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_88,LEN(LEFT(COL_88, CHARINDEX('$', COL_88)+ 1)),LEN(COL_88)),',') END)
+ (CASE WHEN COL_89 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_89,LEN(LEFT(COL_89, CHARINDEX('$', COL_89)+ 1)),LEN(COL_89)),',') END)
+ (CASE WHEN COL_90 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_90,LEN(LEFT(COL_90, CHARINDEX('$', COL_90)+ 1)),LEN(COL_90)),',') END)
+ (CASE WHEN COL_91 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_91,LEN(LEFT(COL_91, CHARINDEX('$', COL_91)+ 1)),LEN(COL_91)),',') END)
+ (CASE WHEN COL_92 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_92,LEN(LEFT(COL_92, CHARINDEX('$', COL_92)+ 1)),LEN(COL_92)),',') END)
+ (CASE WHEN COL_93 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_93,LEN(LEFT(COL_93, CHARINDEX('$', COL_93)+ 1)),LEN(COL_93)),',') END)
+ (CASE WHEN COL_94 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_94,LEN(LEFT(COL_94, CHARINDEX('$', COL_94)+ 1)),LEN(COL_94)),',') END)
+ (CASE WHEN COL_95 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_95,LEN(LEFT(COL_95, CHARINDEX('$', COL_95)+ 1)),LEN(COL_95)),',') END)
+ (CASE WHEN COL_96 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_96,LEN(LEFT(COL_96, CHARINDEX('$', COL_96)+ 1)),LEN(COL_96)),',') END)
+ (CASE WHEN COL_97 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_97,LEN(LEFT(COL_97, CHARINDEX('$', COL_97)+ 1)),LEN(COL_97)),',') END)
+ (CASE WHEN COL_98 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_98,LEN(LEFT(COL_98, CHARINDEX('$', COL_98)+ 1)),LEN(COL_98)),',') END)
+ (CASE WHEN COL_99 IS NULL THEN '' ELSE CONCAT(SUBSTRING(COL_99,LEN(LEFT(COL_99, CHARINDEX('$', COL_99)+ 1)),LEN(COL_99)),',') END))
from oracle_cba_database.[dbo].[CBA_TABLES_TANG] where id=@table_id
declare @DynamicSQL_2 varchar(max)
set @new_column_name =left(@new_column_name, len(@new_column_name)-1)
set @old_table_colum_list =left(@old_table_colum_list, len(@old_table_colum_list)-1)
set @old_table_colum_list=concat(concat('(',@old_table_colum_list,' ',''),')')
--set @old_table_colum_list=replace(replace(@old_table_colum_list,',','],['),' ','')
DECLARE @NEW_GET_VARIBLE_LIST NVARCHAR(MAX)
declare @out nvarchar(max)
print('0')
print(@old_table_colum_list)
set @out=''
select @out=concat(@out,case when @old_table_colum_list like '%'+col_01+'%' then 'COL_01,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_02+'%' then 'COL_02,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_03+'%' then 'COL_03,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_04+'%' then 'COL_04,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_05+'%' then 'COL_05,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_06+'%' then 'COL_06,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_07+'%' then 'COL_07,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_08+'%' then 'COL_08,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_09+'%' then 'COL_09,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_10+'%' then 'COL_10,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_11+'%' then 'COL_11,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_12+'%' then 'COL_12,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_13+'%' then 'COL_13,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_14+'%' then 'COL_14,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_15+'%' then 'COL_15,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_16+'%' then 'COL_16,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_17+'%' then 'COL_17,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_18+'%' then 'COL_18,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_19+'%' then 'COL_19,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_20+'%' then 'COL_20,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_21+'%' then 'COL_21,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_22+'%' then 'COL_22,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_23+'%' then 'COL_23,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_24+'%' then 'COL_24,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_25+'%' then 'COL_25,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_26+'%' then 'COL_26,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_27+'%' then 'COL_27,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_28+'%' then 'COL_28,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_29+'%' then 'COL_29,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_30+'%' then 'COL_30,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_31+'%' then 'COL_31,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_32+'%' then 'COL_32,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_33+'%' then 'COL_33,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_34+'%' then 'COL_34,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_35+'%' then 'COL_35,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_36+'%' then 'COL_36,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_37+'%' then 'COL_37,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_38+'%' then 'COL_38,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_39+'%' then 'COL_39,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_40+'%' then 'COL_40,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_41+'%' then 'COL_41,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_42+'%' then 'COL_42,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_43+'%' then 'COL_43,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_44+'%' then 'COL_44,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_45+'%' then 'COL_45,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_46+'%' then 'COL_46,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_47+'%' then 'COL_47,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_48+'%' then 'COL_48,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_49+'%' then 'COL_49,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_50+'%' then 'COL_50,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_51+'%' then 'COL_51,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_52+'%' then 'COL_52,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_53+'%' then 'COL_53,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_54+'%' then 'COL_54,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_55+'%' then 'COL_55,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_56+'%' then 'COL_56,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_57+'%' then 'COL_57,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_58+'%' then 'COL_58,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_59+'%' then 'COL_59,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_60+'%' then 'COL_60,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_61+'%' then 'COL_61,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_62+'%' then 'COL_62,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_63+'%' then 'COL_63,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_64+'%' then 'COL_64,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_65+'%' then 'COL_65,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_66+'%' then 'COL_66,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_67+'%' then 'COL_67,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_68+'%' then 'COL_68,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_69+'%' then 'COL_69,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_70+'%' then 'COL_70,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_71+'%' then 'COL_71,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_72+'%' then 'COL_72,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_73+'%' then 'COL_73,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_74+'%' then 'COL_74,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_75+'%' then 'COL_75,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_76+'%' then 'COL_76,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_77+'%' then 'COL_77,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_78+'%' then 'COL_78,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_79+'%' then 'COL_79,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_80+'%' then 'COL_80,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_81+'%' then 'COL_81,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_82+'%' then 'COL_82,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_83+'%' then 'COL_83,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_84+'%' then 'COL_84,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_85+'%' then 'COL_85,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_86+'%' then 'COL_86,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_87+'%' then 'COL_87,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_88+'%' then 'COL_88,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_89+'%' then 'COL_89,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_90+'%' then 'COL_90,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_91+'%' then 'COL_91,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_92+'%' then 'COL_92,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_93+'%' then 'COL_93,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_94+'%' then 'COL_94,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_95+'%' then 'COL_95,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_96+'%' then 'COL_96,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_97+'%' then 'COL_97,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_98+'%' then 'COL_98,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
select @out=concat(@out,case when @old_table_colum_list like '%'+col_99+'%' then 'COL_99,' ELSE '' END) FROM [oracle_cba_database].[dbo].[CBA_TABLES] WHERE TABLE_NAME=@targested_table_name
set @out= substring(@out,0,len(@out))
set @new_table_colum_list=substring(@new_table_colum_list,0,len(@new_table_colum_list))
print('1')
print(@out)
print('2')
print(@new_table_colum_list)
print('3')
SET @DynamicSQL_2 = 'insert into '+@new_table_name+'('+ @new_table_colum_list +') select '+@out+' from #Excel_data'
print(@DynamicSQL_2)
EXEC(@DynamicSQL_2)
drop table #Excel_data