{"id":518,"date":"2008-06-04T12:20:59","date_gmt":"2008-06-04T11:20:59","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=518"},"modified":"2008-06-04T12:20:59","modified_gmt":"2008-06-04T11:20:59","slug":"sql-server-upsert-variaciok-5","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2008\/06\/04\/sql-server-upsert-variaciok-5\/","title":{"rendered":"SQL Server UPSERT vari\u00e1ci\u00f3k 5."},"content":{"rendered":"<p>Az upsertes vizsg\u00e1l\u00f3d\u00e1sunk utols\u00f3 r\u00e9sze j\u00f6n, ebben az \u00faj SQL Server 2008 MERGE parancsot haszn\u00e1ljuk:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\ncreate proc dbo.UpsertClient5\r\n  @id int,\r\n  @name nvarchar(100)\r\nas\r\nmerge dbo.Client u\r\nusing (select * from (values (@id, @name)) t(id, name)) t\r\non u.id = t.id\r\nwhen matched then update set u.name = t.name\r\nwhen not matched then insert(id, name) values(t.id, t.name);\r\n<\/pre>\n<p>Eleg\u00e1ns, sz\u00e9p, \u00e9s a harmadik megold\u00e1shoz hasonl\u00f3an itt is j\u00f6hetne be t\u00f6bb sor is, t\u00e1bla t\u00edpus\u00fa param\u00e9terk\u00e9nt. Nincs explicit tranzakci\u00f3kezel\u00e9s, mert bel\u00fcl a parancs eleve tranzakcion\u00e1lis, mint minden DML parancs.<br \/>\nNem biztos, hogy ezzel meggy\u0151ztem b\u00e1rkit is a merger\u0151l, hisz ez csak egy apr\u00f3 alkalmaz\u00e1sa, de \u00e9rdemes mindig szem el\u0151tt tartani, hogy most m\u00e1r nem csak insert, update, delete van, hanem merge is.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Az upsertes vizsg\u00e1l\u00f3d\u00e1sunk utols\u00f3 r\u00e9sze j\u00f6n, ebben az \u00faj SQL Server 2008 MERGE parancsot haszn\u00e1ljuk: create proc dbo.UpsertClient5 @id int, @name nvarchar(100)&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4,30,58],"tags":[],"class_list":["post-518","post","type-post","status-publish","format-standard","hentry","category-adatbazisok","category-szakmai-elet","category-sql-server","category-sql-server-2008"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=518"}],"version-history":[{"count":0,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/518\/revisions"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}