bibi92
asked on
query automatically table which name contains day's number
Hello,
I have automatically perform a select query on a table which contain day depending on the database to insert the data into another table:
example : the 13/10, a select is executed on the test_day_13 table and insert data into the table stats, the 14/10 a select is executed on the test_day_14 table and insert the data in the table stats
Thanks
Regards
I have automatically perform a select query on a table which contain day depending on the database to insert the data into another table:
example : the 13/10, a select is executed on the test_day_13 table and insert data into the table stats, the 14/10 a select is executed on the test_day_14 table and insert the data in the table stats
Thanks
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
darn, sorry Brian
ASKER
Thanks a lot regards
DECLARE @SQL NVARCHAR(4000);
SELECT @SQL = 'INSERT stats (<column list>) SELECT <column list> FROM test_day_' + CAST(DAY(GETDATE()) AS NVARCHAR);
sp_executsql (@SQL);