I want to write query in which name table will dynamicaly compute. I have code like this below. What should I put in 'magic code' region?
DECLARE @myTableName nvarchar(100) = 'sch'
+ CAST(@nowYear as VARCHAR(5))
+ 'Q'
+ CAST(@nowQuarter as VARCHAR(3))
+ '.[tVisits]'
-- magic code --
myTable = DoSomething(@aktTableName)
-- magic code --
SELECT * FROM myTable
I use MS SQL Server 2012