У меня проблема с моим скриптом powershell.Мне нужно вставить в базу данных mssql.
Я получаю:
Исключение вызывает "ExecuteNonQuery" с аргументом (ами) "0": "Неверный синтаксис рядом с '00'."В C: \ powershell \ ImportPism.ps1: 259 char: 9 + $ SqlCmd.ExecuteNonQuery () + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId: SqlException
Вот мой код:
$sql = "
INSERT INTO [dbo].[akcja]
([ak_akt_id]
,[ak_sp_id]
,[ak_kolejnosc]
,[ak_interwal]
,[ak_zakonczono]
,[ak_sc_id]
,[ak_pr_id])
VALUES
(
$($item.akt_id)
,$($item.sp_id)
,0
,0
,$($item.data_dodania)
,NULL
,NULL)
select SCOPE_IDENTITY() as [InsertedId]
"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User Id=$login; Password=$password; Integrated Security = false";
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $sql
$SqlCmd.Connection = $sqlConnection
$SqlConnection.Open()
$InsertedId = $SqlCmd.ExecuteScalar()
$SqlConnection.Close()
Почему это не работает?