I have table in SSMS (SQL Server Management Studio):
from which I need to delete data, based on the SurveyCode
value.
Text part of the SurveyCode
value CSS-2020-08-
is stored in an Excel sheet, in B4
cell, file name Survey.xlsx
:
And, for deleting / adding new data into my Survey
table, I use the following code:
DELETE FROM [WH].[Fact].[Survey]
WHERE [WH].[Fact].[Survey].[SurveyCode] NOT LIKE '%2020-08%'
INSERT INTO
[WH].Fact.[Survey] (
[SurveyCode]
,[SurveyDate]
,[Gender]
,[Age]
,[Questions]
,[Rating]
,[Score]
)
SELECT
staged.[SurveyCode]
,staged.[SurveyDate]
,staged.[Gender]
,staged.[Age]
,staged.[Question]
,staged.[Rating]
,staged.[Score]
FROM
[WH-SSIS].[WHCSS].[Staged_Survey] staged;
Is it possible - instead of using the SQL statement:
WHERE [WH].[Fact].[Survey].[SurveyCode] NOT LIKE '%2020-08%'
to reference CSS-2020-08-
directly from the Excel spreadsheet - right inside the SQL statement?