I have the below script that works however I need some help modifying it.
What I now need to do are the following
1. If the day already exists I need to delete all data from that day and insert the new data for the day.
2. if the day does not exist I need to insert the data for the day.
My date format is written as yyyy-mm-dd hh:mm:ss
In it's current form it only inserts data if the current day is greater than the previous day.
Any help will be greatly appreciated.Declare @Date As Date SET @Date = (SELECT Max(CONVERT(char(10),[Date],102)) FROM [dbo].[ESOEmail_Monthly$]) INSERT INTO [dbo].[ESOEmail_Monthly$] SELECT [EMP_ID] ,[NAME] ,[DEPT] ,[DATE] ,[End Time] ,[LOGOUT] ,[ESO] ,[Team Manager] ,[Senior Manager] ,[SITE] FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=\\VF_RSOSDCNASUDA\fidopost\National_Command\National Command Centre\SQL\ESO\ESO.xlsm;HDR=YES', 'SELECT * FROM [ESOEmail$]') WHERE (CONVERT(char(10),[Date],102) > CONVERT(DATETIME, @Date, 102))
Thanks




Reply With Quote