powershell 从powershell将数据插入表中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 从powershell将数据插入表中相关的知识,希望对你有一定的参考价值。

$strConnectionString = "Password=FaY5FEC5;Persist Security Info=True;User ID=OPWDataWriter;Initial Catalog=OPWBI;Data Source=opwsql03\sp2013tabular";
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = $strConnectionString
$conn.open()
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.connection = $conn
$d = Get-Date
$cmd.commandtext = "INSERT INTO Automated_Process_Tracker (StartTime,EndTime,Process,Status,Note) VALUES('{0}','{1}','{2}','{3}','{4}')" -f $d,$d,"Test","TestAgain","TestLast"
$cmd.executenonquery()
$conn.close()

以上是关于powershell 从powershell将数据插入表中的主要内容,如果未能解决你的问题,请参考以下文章

将输入变量从PowerShell表单传递到cmdlet参数会导致空白数据

将变量从厨师传递到PowerShell

PowerShell - 从 csv 文件读取数据,比较特定列中的数据并将结果写入新文件

从 MATLAB 调用 Powershell 不会移动到 MATLAB 中的下一行

将变量从 Powershell 脚本传递到 SQLPlus

从 Powershell 调用的 DLL 使用相对于 Powershell 安装目录的路径。如何将其设置为其他内容?