Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-25 : 18:43:01
|
| Hello,I want to know what is the different between Match By Target and match by Source in MERGEANDNot Match by Target and Not Match by Source lastly : when can I use them exactly?also how can I insert into source table instead of target, and how can I delete from source table instead of target....!!Thank you :) |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-25 : 18:56:47
|
| target is the merge table, source is the using table.So not matched by target is when there is a row in the using table that is not in the merge table - and you usually want to execute an insert.Mathed by target and source - this is just matched - there is a row in the source and target and you usually check to see if there is a difference in the non-key columns and do an update.You can't affect the using table (which doesn't even have to be a table - it's often a cte. You can output to a table variable and use that in a following statement though.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-25 : 19:17:43
|
| thank you nigelrivett |
 |
|
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-26 : 01:34:42
|
| what is default ,do I must write (by Source) or (by Target) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-04-26 : 04:26:46
|
quote: Originally posted by jooorj what is default ,do I must write (by Source) or (by Target)
Depends what you want to do. Two different options for two different scenarios. Read Nigel's post again--Gail ShawSQL Server MVP |
 |
|
|
|
|
|