SQL Server Merge T-SQL Command Two Tables With Same Columns Must See!

Опубликовано: 08 Ноябрь 2021
на канале: Software Nuggets
4,426
27

If you are interested to learn more about SQL Server merge command, this is the correct video to watch!

This video is all about SQL Server merge command. I will show by example how to use this incredible command:
-SQL merge two tables with same columns
-merge statement in SQL example

Source Table - A table that contains all the changes.
Target Table - A different table that will receive all those changes.

Perform Insert, Update and Delete in one statement. This video only shows Insert and Update.

Thank you for dropping in, I hope you'll find all the information you'll need to successfully use this command.

Source code for this video.

create table web (
order_id int,
has_shipped bit
)

insert into web(order_id,has_shipped)
values
(1,'true'),
(2,'true'),
(3,'true'),
(4,'true')

create table production
(
order_id int,
has_shipped bit
)

insert into production(order_id, has_shipped)
values
(1,'false'),
(2,'false'),
(3,'false')

merge production as T
using web as S
on (t.order_id = s.order_id )
when matched then
update SET T.has_shipped = S.has_shipped
when not matched by target then
insert (order_id, has_shipped) values (S.order_id, S.has_shipped);


На этой странице сайта вы можете посмотреть видео онлайн SQL Server Merge T-SQL Command Two Tables With Same Columns Must See! длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Software Nuggets 08 Ноябрь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 4,426 раз и оно понравилось 27 зрителям. Приятного просмотра!