I have several tables divided by year, tab_2014, tab_2015
I try to construct sql command as below.
val tab_name = "[AQMSDB].[dbo].[Tab_" + DateTime.now.getYear + "]"
Logger.info("tab_name:" + tab_name)
sql"""
SELECT TOP 1 M_DateTime
FROM ${tab_name}
ORDER BY M_DateTime DESC
""".map { r=>r.timestamp(1) }.single.apply
During execution, I got an error from Microsoft SQL JDBC driver.
It said I must declare a table variable.
I am confused why I need to declare a tab variable to make it a dynamic sql.
After all, scalikeJDBC is only using string interpolation.
Any work around or any suggestion?
Thank you