Hello everyone ,
I want to pass a table name as a variable, here is what I am trying to do, please advise, thank you.
I have test_table_old which have create_date column and I am trying to insert data into temp_table_new only after the max create date from the Temp_table_new, I can do this fine for one table, but I have a few of them and I wanted to pass names of the table as a parameter, please advise, thank you.
DECLARE @createdatetemp DATETIME, @Tablename VARCHAR(50)
SET @Tablename= Any of the tem_test_old
SET @createdatetemp= (SELECT MAX(create_date) FROM @Tablename)
INSERT INTO Temp_table_new
SELECT *
FROM tem_test_old
WHERE create_date >= @createdatetemp