I have folder in which I have a file that get dump every hr into it and I want to figure out how can I ingest the lastest file into my SQL server data dump?
Figure I need to write in a wildcard somewhere and a last modified date to ingest it.
File Name |
Modified Date |
SQL_File -74541445 |
7/5/2024 7:00AM |
SQL_File -78542100 |
7/5/2024 8:00AM |
SQL_File -45212445 |
7/5/2024 9:00AM |
You can use a wild-card like this. You need the LIKE instead of = and % is the wildcard. In below query you will get all [File Name] witch start with SQL_File.
SELECT [File Name]
FROM YourTable
WHERE [File Name] **LIKE** 'SQL_File%'
To get the latest Modified Date you can do something like this:
SELECT MAX([Modified Date]) AS LastModifiedDate FROM YourTable
If you combine this into 1 query you get something like this:
SELECT [File Name]
FROM YourTable
WHERE [File Name] **LIKE** 'SQL_File%' AND [Modified Date] = (SELECT MAX([Modified Date]) AS LastModifiedDate FROM YourTable)