Below is the Stored procedure I am working with. The Data I am getting in the CSV file is prone to having duplicate information in it from previous days. So I created an Identity Field with an ID and the Date included and set it as the PK for the table in the hopes of importing the data without creating duplicate records. Of course now the SP fails due to PK violations when the duplicate records are incountered so I modified my original SP with the following. But I am getting the following messge when I run the SP. I create the temp table with the Column and have it though out the code, just not seeing where I am missing it. Msg 4104, Level 16, State 1, Procedure usp_ImportMultipleFiles, Line 65The multi-part identifier "#PayRollData.WORKEDINSeconds" could not be bound.declare @query varchar(1000)declare @max1 intdeclare @count1 intDeclare @filename varchar(100)declare @Filepath varchar(500)declare @pattern varchar(100)declare @TableName varchar(128)set @count1 =0set @Filepath = '\\susagpwfm01\TRE_Files\'set @pattern = '*.csv'set @TableName = 'tbl_Payroll'create table #x (name varchar(200))set @query ='master.dbo.xp_cmdshell "dir '+@Filepath+@pattern +' /b"'insert #x exec (@query)delete from #x where name is NULLselect identity(int,1,1) as ID, name into #y from #x drop table #xset @max1 = (select max(ID) from #y)--print @max1--print @count1While @count1 <= @max1begin--Set @Filepath = 'NET USE \\susagpwfm01\TRE_Files urban2009/User:worldshipups1 'Set @Pattern = '*.csv'set @count1=@count1+1set @filename = (select name from #y where [id] = @count1)set @query ='BULK INSERT '+ @Tablename + ' FROM "'+ @Filepath+@Filename+'" WITH ( FIELDTERMINATOR = '','', ROWTERMINATOR = ''\n'')'--Print @TableName--Print @FilePath--Print @FileNameprint @queryexec (@query)SET IDENTITY_INSERT SCCC_DB.dbo.tbl_PayRollData ONCREATE TABLE #tblPayroll (PayRollID nchar(50))CREATE TABLE #PayRollData (PayRollID nchar(50), EmployeeID int, StartDate datetime, TIMERECORDID int, ExternalID int, TempDept int, ActivityType nchar(6), WORKEDINSeconds int, Is_Paid bit) INSERT INTO #PayRollDataSELECT EmployeeID + REPLACE(Startdate, '/', '_') AS PayRollID, EmployeeID, Startdate, TIMERECORDID, ExternalID, CASE WHEN OrganizationName = N'ITHD TRETON' THEN N'999928' ELSE N'249983' END AS TempDept, CASE WHEN tbl_Payroll.Activity IN (N'PTO', N'JD', N'HOL') THEN Activity ELSE N'WORKED' END AS ActivityType, SUM(CASE WHEN TIMERECORDID IS NULL THEN CONVERT(decimal, Duration) * 3600 ELSE DATEDIFF(ss, StartDate + CONVERT(datetime, StartTime), EndDate + CONVERT(datetime, EndTime)) END) AS WORKEDINSeconds, CASE WHEN IsPaid = N'True' THEN 1 ELSE 0 END AS Is_PaidFROM tbl_PayrollGROUP BY TIMERECORDID, ExternalID, EmployeeID, CASE WHEN IsPaid = N'True' THEN 1 ELSE 0 END, CASE WHEN OrganizationName = N'ITHD TRETON' THEN N'999928' ELSE N'249983' END, CASE WHEN tbl_Payroll.Activity IN (N'PTO', N'JD', N'HOL') THEN Activity ELSE N'WORKED' END, Startdate, EmployeeID + REPLACE(Startdate, '/', '_')HAVING (CASE WHEN IsPaid = N'True' THEN 1 ELSE 0 END = 1)UPDATE SCCC_DB.dbo.tbl_PayRollDataSET SCCC_DB.dbo.tbl_PayRollData.WORKEDINSeconds = #PayRollData.WORKEDINSecondsOUTPUT inserted.PayRollID INTO #tblPayrollFROM SCCC_DB.dbo.tbl_PayRollData a INNER JOIN #PayRollData b ON a.PayRollID = b.PayRollIDINSERT INTO tbl_PayRollDataSELECT *FROM #PayRollDataWHERE EMPLOYEEID IS NOT NULL AND PayRollID NOT IN (SELECT PayRollID from #tblPayRoll)DROP TABLE #PayRollData--Clean up Imported Payroll Data for the Next ImportDELETE FROM [SCCC_DB].[dbo].[tbl_Payroll]endEXEC master..xp_cmdshell 'MOVE \\susagpwfm01\TRE_Files\*.csv \\susagpwfm01\TRE_Files\Processed'