Merge not inserting new values

I’m trying to use MERGE to insert new values to a table only if they don’t already exists in the same table. This is the query I am using: MERGE [dbo].[TARGET_TABLE] AS Target USING (SELECT [NAME] …

Update a Table Variable Where Not Exists

UPDATE @Customer SET ValidaitonAction = 1 WHERE NOT EXISTS (SELECT 1 FROM DMScustomerupload WHERE AccountNumber = @Customer.AccountNumber) Where @Customer is a TABLE variable: DECLARE @…

Trying to replace a Cross Apply with a JOIN

We have a table, ProductHierarchy, which is set. The # of rows will not change. It has simple parent/child Product Hierarchy data in it. We also have a Table-valued function which takes a …

SQL server: How to Modify a JSON element value in a nested JSON array

If i have below JSON (@CarDataJsontest) e.g { “house”: { “gate”: [ “Car1”, “Car911”, “Car3”, “Car4” ] } } If i need to do is to modify the car911 to car2 all i …