sqlCommand.CommandText = "EXEC sp_UPSERT_MYFILETABLE @Customer_ID, @MyFile"
sqlCommand.Parameters.Add(New SqlParameter("@MyFile", SqlDbType.VarBinary)).Value = File.ReadAllBytes(MyFileLocation)
sqlCommand.Parameters.Add(New SqlParameter("@MyFile", SqlDbType.VarBinary)).Value = DBNull.Value
@id int,
@MyFile varbinary(MAX),
@Customer_ID int,
@Username varchar(30),
@Password varchar(30),
@AnotherValue varchar(30)
AS
BEGIN
MERGE INTO dbo.Remote_Access_Details AS target
USING (
VALUES (@id
,@Customer_ID
,@Username
,@Password
,@AnotherValue)
) AS source (id
,Customer_ID
,Username
,Password
,AnotherValue)
ON target.Customer_ID = source.Customer_ID
WHEN MATCHED
THEN UPDATE
SET id= source.id
,Username= source.Username
,Password = source.Password
,AnotherValue = source.AnotherValue
WHEN NOT MATCHED
THEN INSERT (Id
,Username
,Password
,AnotherValue)
VALUES (Id
,Username
,Password
,AnotherValue);
END
RETURN