Hi I have a csv file with the columns as below. The column names and order of columns can be changed.
DeptID|Dname|Loc or DeptName|Dept_id|Location or Loc_ID|Dept_ID1.
I got a requirement that if the column comes with different names I need to check the combination , if any of the value matches, I need to add the columns in insert statement.
For this I have created a table as
create table DeptConfig(ID INT Identity(1,1),ColName VARCHAR(50),ColValue VARCHAR(500)); The colname value represents the original column name of Dept Table.
INSERT INTO DeptConfig values('Deptid','Deptid,Dept_id,Deptid1,Dept_id1')
go
INSERT INTO DeptConfig values('Dname','Dname,Deptname,Dept_Name')
GO
INSERT INTO DeptConfig values('Loc','Loc,Location,Loc_Name')
go
INSERT INTO DeptConfig values('Dname','Dname,Deptname,Dept_Name')
GO
INSERT INTO DeptConfig values('Loc','Loc,Location,Loc_Name')
Actual Table Structure is Dept is the tablename (DeptId int,Dname VARCHAR(50),Loc VARCHAR(50))
By using Deptconfig Table How can I achieve my requirement.
Please let me know if I miss some thing.