I want to use a query that uses another file if that file does not exist. I ran the following query in Synapse's Serverless SQL and got an error.
BEGIN TRY
SELECT *
FROM
OPENROWSET(
BULK 'https://dls001dev.dfs.core.windows.net/published/test/year=2023/month=05/test05.parquet',
FORMAT = 'PARQUET'
) AS [result]
END TRY
BEGIN CATCH
SELECT *
FROM
OPENROWSET(
BULK 'https://dls001dev.dfs.core.windows.net/published/test/year=2023/month=04/test04.parquet',
FORMAT = 'PARQUET'
) AS [result]
END CATCH
And error message is here.
File 'https://dls001dev.dfs.core.windows.net/published/test/year=2023/month=05/test05.parquet' cannot be opened because it does not exist or it is used by another process.
It is true that 'https://dls001dev.dfs.core.windows.net/published/test/year=2023/month=05/test05.parquet' does not exist, but instead of returning an error in this case, we would like to use 'https://dls001dev.dfs.core.windows.net/published/test/year=2023/month=04/test04.parquet' instead of returning an error in this case.
1条答案
按热度按时间2vuwiymt1#
EXEC
orsp_executesql
returned the required result.sp_executesql
.