I'm trying to create a table
like
select x.*, convert(nvarchar(20), getdate(), 101) AS LoadDateinto table1_20140512
from (
select c1,c2,c3 from table2_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM table2_20140512 )
union all
select c1,c2,c3 from table3_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM table3_20140512 )
) X
I want to make table name dynamic, like 'table1'+toady's date
I declared three variables, but they didn't work as I expected
These are my variables
DECLARE @table1 nvarchar(500)
DECLARE @table2 nvarchar(500)
DECLARE @table3 nvarchar(500)
SET @table1='H1_' +(CONVERT(VARCHAR(8),GETDATE(),112))
SET @table2='H2_' +(CONVERT(VARCHAR(8),GETDATE(),112))
SET @table2='H3_' +(CONVERT(VARCHAR(8),GETDATE(),112))