我有一个脚本,它通过zip文件将数据输入数据库,解压后首先移动数据,然后插入数据库中的数据 CSV
,由解压产生,在表中。现在我想修改这个脚本,只从另一个数据库和表中获取数据,但是我需要能够将这些数据放在 CSV
数据丢失了。
USE [$(DataTools)];
GO
DECLARE @LoadJob VARCHAR(64) = '208_table';
DECLARE @LoadStep VARCHAR(64) = 'spMoveUnzipLoad';
DECLARE @PreLoad VARCHAR(128) = CONCAT('etl.spChangeFileEncodingAsMUZLPreLoad ''', @LoadJob, '''');
DELETE FROM [load].LoadParameters WHERE loadJob = @LoadJob;
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'copyOrMoveFile' , 'move';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'doNotUnzipFile' , '0';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'FileMask' , 'data.csv.gz';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'firstRow' , '2';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'forLoadFolderName' , '\ForLoad';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'formatFile' , '\208_Customers.fmt';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'loadedFolderName' , '\Loaded';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'notLoadedFolderName', '\NotLoaded';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'sourceFolderName' , '$(SourceFileLocation)';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'targetDatasetName' , 'table_Staging';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'targetDatabaseName' , '$(DatabaseName)';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'truncate' , '1';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'unzipFolderName' , '\208_Customers\Unzip';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'PostLoadSql' , 'test_PostLoad';
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'PreLoadSql' , @PreLoad;
EXEC [load].setLoadParameter @LoadJob, @LoadStep, 'workingFolderName' , '\208_Customers\Working';
------------------------------------------------------------------------------------------------------------------------
-- End of Script
------------------------------------------------------------------------------------------------------------------------
如何更改此脚本以从表中获取数据?它会改变还是需要重新创建?
1条答案
按热度按时间hwamh0ep1#
您可以使用脚本创建数据库结构,同时将数据数据库内容加载到结构中。查看ssms导出小部件以导出数据库(结构和数据内容)。