-- Create Target Table
CREATE TABLE dbo.Sales (Id int,
SalesAmount money);
INSERT INTO dbo.Sales VALUES(1,10.99);
-- Create Source Table
CREATE TABLE dbo.NewSalesNAdjustments(Id int,
SalesAmount money);
INSERT INTO dbo.NewSalesNAdjustments VALUES (1, 12.99);
INSERT INTO dbo.NewSalesNAdjustments VALUES (2, 5.99);
go
merge sales t ---target
using newsalesNAdjustments as S ---Source
on t.id=s.id
when matched then ---update
update set t.salesamount=s.salesamount
when not matched then ---insert
insert (id,salesamount) values(s.id,s.salesamount);
---verify upsert operation
select * from sales
go
merge sales t
using NewsalesNadjustments as s
on t.id = s.id
when matched then update set t.salesamount=s.salesamount
when not matched then insert (id,salesamount) values(s.id,s.salesamount);
select * from sales
Subscribe to:
Post Comments (Atom)
Search This Blog
DAX - Grouping on multiple columns and the count
Please go thorugh the below URL for entire soultion. http://community.powerbi.com/t5/Desktop/DAX-Grouping-on-multiple-columns-and-the-cou...
-
Synchronous vs Asynchronous The SSIS dataflow contain three types of transformations. They can be non-blocking, semi-blocking or full...
-
--SHRINKFILE and TRUNCATE Log File in SQL Server SELECT DB_NAME(database_id) AS DatabaseName, Physical_Name, Name AS Logical_Na...
-
The main statement used to retrieve data in T-SQL is the SELECT statement. Following are the main query clauses specified in the order that...
No comments:
Post a Comment