Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created a history table to take a back of my table and Know I want to load this history table with table data.

Problem is for every new table I will dynamically create a History.Table. I can't use history table as my destination in SSIS. So I have to use stored procedure passing my @Filename= History.table name as variable.

But I am not able to do pass @Filename= History.table as variable
How to load data in Dynamically generated History.Table?
Posted

1 solution

I'm not sure what you want, but you can pass table name in this way:
SQL
ALTER PROCEDURE ...
    @dbname NVARCHAR(30)
    @tablename NVARCHAR(30)
AS
BEGIN

DECLARE @sql NVARCHAR(200)

SET @sql = 'SELECT * FROM [' @dbname + '].[dbo].[' + @tablename + ']'
EXEC(@sql)

END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900