Catch Exception Calling "executenonquery"
I have a Powershell script that inserts a primary key value and another value into a SQL Server 2012 database. This is the INSERT SQL string that includes IF NOT EXISTS, where $sql
Solution 1:
$SQL_UPDATE = "BEGIN
IF NOT EXISTS (SELECT 1
FROM dbo.Download
WHERE Date_of_Download = CAST(GETDATE() AS DATE))
BEGIN
INSERT INTO dbo.Download (Date_of_Download , OtherColumnName)
VALUES (CAST(GETDATE() AS DATE) ,$sql_output)
END
END"
Post a Comment for "Catch Exception Calling "executenonquery""