小编cod*_*ger的帖子

在 SQL Server 代理中执行的 Powershell 脚本

我正在尝试在 SQL Server 代理作业中使用 Powershell 下载 zip 文件。该脚本使用 PuTTY (PSCP.exe) 从 SFTP 站点下载 zip 文件。

我遇到的问题是,当作业运行时,它会连接到 SFTP 站点,并且 PuTTY 会发回有关将服务器的主机密钥存储在注册表中的提示。我不想这样做,所以我试图将echo n命令通过管道传输到 PuTTY。但这似乎不起作用。

$SrcPath = "/somedirectory/somewhere/files/"
$DstPath = "D:\Download\"
$currentDate = (Get-Date).ToString('yyyyMMdd')
$FileName = "$currentDate.zip"
$ArchivePath = "D:\Archive\"

$File = "$SrcPath$FileName"

Set-Location $DstPath

echo n | C:\"Program Files (x86)"\PuTTY\pscp -P 99999 -pw password username@{IP_ADDRESS}:$File $DstPath
# Check the file is there
If (Test-Path "$DstPath$FileName")
{
  # Unzip the contents
  C:\"Program Files"\7-Zip\7z.exe e "$DstPath$FileName"
  #Move the zip file to the …
Run Code Online (Sandbox Code Playgroud)

powershell sql-server-2012 sql-server-agent

5
推荐指数
1
解决办法
2459
查看次数

如何处理重复的查找信息

我有多个数据库要存储在一个数据仓库数据库中。我想知道如何设计导入过程来处理多个查找表。

例如,假设我有 5 个数据库,所有数据库都带有查找表 CustomerState。在一个数据表中,它可能如下所示:

在此处输入图片说明

在另一个数据库中,它可能如下所示:

在此处输入图片说明

我应该如何在我的 DW 数据库的企业层中处理这个问题?我是否将 SourceSystemId 添加到查找表中,可能是这样的:

在此处输入图片说明

然后在我的客户表中使用 pkyCustomerStateId 而不是 CustomerStateId?

data-warehouse database-design sql-server

3
推荐指数
1
解决办法
111
查看次数