A SQL statement typically used to `UPDATE` records when they exist and `INSERT` them when they do not.

learn more… | top users | synonyms

1
vote
0answers
30 views

Unable to get stable set of rows

I am trying to update latitude/longitude where missing using a merge statement. It errors: ORA-30926: unable to get a stable set of rows in the source tables. I thought that meant that the inner query ...
0
votes
0answers
10 views

SQL Server Merge - returning error messages properly - finding record where error occured

I have a table structure like: Parent - Child 1 - Child 2 - Child 3 In two databases, one of them has some extra fields. I want to get the data(which can be huge) from one database into another ...
0
votes
0answers
10 views

Are tables during a merge function updated dynamically?

If for example, I have a column age in both tables. My merge condition for two tables is when table1.age=table2.age. My WHEN MATCHEDinstruction is to increment table1.age by 1. So if a row with age=5 ...
1
vote
0answers
27 views

Mysteriously Updated Rows

Yo, heres the trigger causing the Problem USE [SalesDb] GO /****** Object: Trigger [dbo].[trgAfterUpdate] Script Date: 7/16/2015 6:34:01 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON ...
0
votes
0answers
31 views

Merging data from two slightly different datasets

A bit of backstory: we used to have a single Postgresql db that we had to duplicate when we opened a new office. So at that moment there were two indipendent dbs with perfectly identical data. Over ...
1
vote
0answers
42 views

SQL Server tool for merging rows [closed]

We have a SQL Sever 2008 database that occasionally receives bad data from customers. The issue we are trying to address here is that sometimes duplicate records are created where one row has some of ...
1
vote
0answers
39 views

Merging Databases with Same Schema

I have been developing a (MySQL) database in the cloud for the past few months to link in to a web based service. Following a change to the roadmap the initial clients will be running on standalone ...
2
votes
1answer
71 views

moving a Partition of Partitioned Table to other File Group, SQL Server

I created partitioned table on DateTime column. for last 6 month. I placed 3 oldest month on a file group named 'FG_OlderData', and 3 newest month on a file group named 'FG_NewerData'. Partition ...
0
votes
3answers
120 views

Merge replication throws PRIMARY KEY violation during the initialization of Subscriber

I am using SQL Server 2014 SP1 to set up merge replication on Windows 2008. The databases (Publisher & Subscriber) are restored from the production back up of SQL Server 2005 publisher database. ...
0
votes
0answers
12 views

After merge replication setup, tables at subscriber not getting any data from publisher

I have created a merge replication setup through Replication Wizard. After sync, it is observed that the subscriber DB gets created with the exact tables in publisher as intended, but on the ...
7
votes
1answer
234 views

Merge row size overflow in SQL Server - “Cannot create a row of size..”

The target table to which I'm trying to merge the data has ~660 columns. The code for the merge: MERGE TBL_BM_HSD_SUBJECT_AN_1 AS targetTable USING ( SELECT * FROM ...
3
votes
1answer
88 views

how would i merge a column where matches a different column? [closed]

It's very similar to the below post How to merge column in mysql depending on match table user I would like to Merge customer_id from table user to table cust where customers_firstname AND ...
0
votes
1answer
60 views

SELECT ROWS WITH SIMILAR ID AND MERGE THE FILED VALUES IN ONE

My situation is as follows. I have the query below and the query is doing its job pretty well. However I have excluded one able from it which is field_data_field_luogo and the rows inside this can ...
1
vote
2answers
140 views

Merge faster than Insert

Are there any advantages/disadvantages of making use of a merge over a insert function? Can an insert statement make use of the `OUTPUT' Note: the ON clause for the merge is set to 1=0 (always ...
1
vote
1answer
92 views

Shorthand for on primary key?

Is there a shorthand for merging rows based on the primary key? For example: MERGE INTO [MyDatabase].[MySchema].[MyTable] AS target USING [MyLinkedServer].[MyDatabase].[MySchema].[MyTable] AS source ...
0
votes
0answers
43 views

Is this MERGE statement correct?

Question: Is this MERGE statement correct ? emphasis on the ON and AND .. are they rightly placed? MERGE INTO VR_ORDER_LINE USING (SELECT * FROM E14) ON ( VR_LINE.RETAIL_NUMBER = ...
0
votes
0answers
44 views

What is “Set the merge agent on the problem subscribers to use the slow link agent profile”

I have never used Merge Replication Feature of the sql server before, so What does "Set the merge agent on the problem subscribers to use the slow link agent profile" mean? Background info: "Merge ...
0
votes
1answer
253 views

Insert All Columns from one table into another table MYSQL

I am trying to insert multiple columns with their data from one table into another table, without a common column (i would expect a cross product in the result). I am not sure how that's possible, ...
1
vote
1answer
264 views

How do I update and insert specific set of rows to an existing table using Merge in SQL Server 2008 R2?

I have a table in the database that I need to update based on the records being passed to it. I am given a table-valued-parameter that has the same schema as the existing table (for all intensive ...
0
votes
2answers
897 views

How to insert or update using single query?

I have a table test having columns id which primary key and auto incremented and name. I want to insert a new record if annd only if there are no records.For example input is id=30122 and name =john ...
1
vote
0answers
144 views

Executing shell commands from SSDT Post Deploy scripts to generate SQL

tl;dr: I'm looking for the equivilant of !! sqlcmd -S $(Server) -o foo.sql -d $database -Q "EXEC sp_generate_merge 'table_name'" in a SSDT post deploy script, but !! doesn't seem to be supported. I ...
0
votes
0answers
91 views

Oracle 12G Merge subpartition data into partition

I have a Oracle 12G table which is interval partitioned (monthly) and list sub-partitioned. There is no longer a requirement to sub-partition the table and hence I would like to "merge" the data in ...
0
votes
1answer
52 views

Automating SQL Server Merge Replication Processes [closed]

Hi all is there anyway I can automate the entire process of the Merge Replication?
0
votes
0answers
174 views

How to merge exported SQL Data into restored DB updating only changed rows?

We've just moved two databases from Microsoft SQL Server 2008 instance to another using BACKUP DATABASE on the original system and then RESTORE DATABASE on the new one. Everything went fine but then I ...
1
vote
2answers
368 views

Stored procedure - problem with merge - Insert

I am calling a stored procedure from my c# code . The procedure works fine for update, but fails for Insert. Is the following merge-insert procedure code correct? Any help is appreciated. Here is ...
1
vote
0answers
35 views

SCD2 loading With Merge but without delete (multiple if matched) [closed]

Hoping someone can solve an issue for me. I'm very new to sql in general but with some research I've completed nearly 75% of the task. Basically, I need to compare an incoming file against my fact ...
0
votes
1answer
56 views

Merge two rows into one row

So I have a table that looks like this: And here's my query for that table: select b.Barcode,a.ItemCode,b.Color,b.Size,b.Class,d.Locationcode,c.price, SUM(case when e.description = 'Selling ...
0
votes
1answer
38 views

MSSQL 2000 replication, incrementing an integer column on a single row using an update statement

I have 2 web servers, both of which connect to separate mssql 2000 database servers, these two servers use merge replication in order to collate tracking data. Now each web server runs an update ...
1
vote
1answer
402 views

Merge Problems SQL Server

I'm trying to create a procedure that will take the values from a temporary table, and load them into another table. The second table has a composite unique constraint across its three columns (Not ...
0
votes
1answer
55 views

Can't map invalid columns based on column names in a .dtsx-Package

I have the following problem. I currently have to modify a .dtsx-Package which was originally created by a coworker who is not arounf anymore. This package contains some logic but above all it does ...
0
votes
0answers
279 views

merge in cursor is slow ,any alternative for that in oracle 11g

we have a requirement like below. we need to update one table A from another table B based on joining criteria. both tables are having porper joining columns. Table A has 2 columns missing_order_cw ...
1
vote
1answer
142 views

Query hint? for deduplicated CTE in Merge

Referring to this link: Optimizing MERGE Statement Performance The following criteria are given for ideal performance: Create an index on the join columns in the source table that is unique and ...
1
vote
1answer
186 views

MySQL: Merge Same Database on Several Location into Single Location

I have registration form, which exactly same for several location. Each of them has REG column, which this field is unique for each row. Basically each data input have different REG number for it, ...
1
vote
1answer
79 views

Merge a table into an existing one

I know how to JOIN two tables as create a new table out of the results, using CREATE TABLE result_table AS ( SELECT * FROM tableA JOIN tableB ). I forgot to include some columns from the JOIN in the ...
3
votes
2answers
3k views

Way to do MERGE with update source when target not match?

I am trying to write a stored procedure that will take new values from a temp table, merge them into an actual table, giving me the ids of the inserted rows, and the rows that already exist matching ...
0
votes
0answers
712 views

The OLE DB provider “SQLNCLI10” for linked server “(null)” indicates that either the object has no columns or

When I run the following script its run fine merge RDW_RRR_MAIN_ST.dbo.tmps AS dest USING (select * from RDW_RRR_MAIN_ST.dbo.tmprole cross join RDW_RRR_MAIN_ST.dbo.tmpscreen) as src1 on ...
1
vote
2answers
275 views

Update row where associated row does not exist

Given the table named ROLE: role_id[PK] NUMBER role_name VARCHAR2 Using only SQL (no PL/SQL) how would I write a MERGE (or UPDATE?) statement that would update the role_name as below, but only ...
3
votes
1answer
129 views

3 table merge with some condition

I am new to this forum and I am learning mysql with the help of online resources, currently I am trying to compare and merge table with some conditions Fiddle These are my tables; ...
0
votes
1answer
621 views

Multiple table rows in one row Informix

I have problem just like this one but in Informix. I have table with 2 attributes ID, email like this one: ID email 1 my_mail1@mail.com 2 my_mail2@mail.com 2 my_mail3@mail.com 2 ...
1
vote
0answers
124 views

RETURNING syntax with multiple columns

Again, another question related to the answer of the one there: Insert with OUTPUT correlated to sub query table So I ended up with this query, written for SQL Server: CREATE TABLE tempIDs ( ...
4
votes
1answer
367 views

A clarification of MERGE best practices

I just wanted to ask a clarification about something on the MSDN from the "Optimizing MERGE Statement Performance" page. I am working with a data warehouse that takes in records from many different ...
0
votes
3answers
34k views

SQL Server - Copy data from one database to another - identical tables, new identity values needed

Here's the thing, I have been running identical copies of my website for two different geographical regions. The site now supports multi-currency pricing so I want to merge both sites together. All ...
3
votes
1answer
89 views

Does MERGE updates when not needed?

In SQL Server 2012, Does a merge statement like this : WHEN MATCHED THEN update SET A.len = B.len updates a row even if A.len equals to B.len ? Or does the SQL SERVER knows to ignore this ...
0
votes
0answers
169 views

Merge Similar Schema from one MySQL DB to Another

I have two databases (db1 and db2). db2 has all tables from db1 but not necessarily the same columns. I want to move any missing columns in db2 from tables in db1 but keep the rest unchanged. ...
3
votes
2answers
2k views

Merging two backups form a postgresql database

I have a kind of big postgresql database and two backup files (each uncompressed dump file ~56 mb) representing 2 states of the data in time. 1st state - backup from a couple days ago 2nd state - ...
1
vote
0answers
115 views

How to merge rows based on how much data they have?

I am cleaning data and I formed a table something like this: file | product | color | product_id --------------------------------------------- one.csv pipe blue null ...
1
vote
1answer
310 views

Merge Fields into one Row with a Query

I am working with Microsoft Office Professional Plus 2010. What I am trying to figure out is how to merge all characters for each DOMAIN field into one row, for example: Q01 ...
1
vote
1answer
1k views

Problem using merge into a remote table over dblink

I'm attempting to perform a merge into a remote table, let's say on server A (over a dblink), using a local table on server B. Source and target databases are both on Oracle 10.2.0.3. We already have ...
0
votes
0answers
2k views

Oracle merge query vs correlated update

I have a query which updates a table with data from another table. The current query is written as a correlated update with an exists clause to remove unnecessary rows. The problem is since both of ...
2
votes
4answers
7k views

How do I delete only related records in a multi-key MERGE in SQL Server?

Suppose you have something like this: Source table (variable): Values ( LeftId INT NOT NULL, RightId INT NOT NULL, CustomValue varchar(100) NULL ) Target table: Mapping ( LeftId INT NOT ...