如何加载动态创建的表 [英] How to load Table created Dynamically
本文介绍了如何加载动态创建的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个历史表来取回我的表,并且知道我想用表数据加载此历史表.
问题是对于每个新表,我都会动态创建一个History.Table.我无法将历史记录表用作SSIS中的目的地.因此,我必须使用存储过程,将我的@ Filename = History.table名称作为变量传递.
但是我无法通过@ Filename = History.table作为变量
如何在动态生成的History.Table中加载数据?
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?
推荐答案
我不确定您想要什么,但是可以通过这种方式传递表名:
I''m not sure what you want, but you can pass table name in this way:
ALTER PROCEDURE ...
@dbname NVARCHAR(30)
@tablename NVARCHAR(30)
AS
BEGIN
DECLARE @sql NVARCHAR(200)
SET @sql = 'SELECT * FROM [' @dbname + '].[dbo].[' + @tablename + ']'
EXEC(@sql)
END
这篇关于如何加载动态创建的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文