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 |
jamesbrummel
Starting Member
5 Posts |
Posted - 2013-01-08 : 13:20:18
|
I'd like to use MERGE to get a list of non-matched records, but I don't want to insert them into the target table.I can use OUTPUT to insert the non matches to a @table, but can't seem to prevent MERGE from INSERTING, I don't want to take any action other than to insert non matches into @table.Thanks!!! |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-01-08 : 13:33:18
|
then you should insert non matches into @table without merge and that output stuff... Too old to Rock'n'Roll too young to die. |
|
|
jamesbrummel
Starting Member
5 Posts |
Posted - 2013-01-08 : 14:17:28
|
I am trying to use the comparison that occurs in the MERGE functionunder the assumption it will be faster than a field by field comparison of each row which I can code. My experience has been that built in SQL functions are much faster than anything I can code.Is this not the case here,maybe? I would assume this would be common practice if there is a substantial performance gain over a proc. |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2013-01-08 : 15:38:40
|
I'm not following your logic; a Merge statement still requires you to do the comparison of the columns you want to evaluate equality/inequality against (unless you did a checksum comparison or something). Additionally, a Merge statement can be used by itself (ad-hoc) or in a procedure. So, comparing it to a stored procedure doesn't really have any meaning. |
|
|
jamesbrummel
Starting Member
5 Posts |
Posted - 2013-01-10 : 11:40:35
|
ahh, I think I see what you mean. In the MERGE I have to explicitly state ON colA=ColB, colC=ColD, etc.essentially doing a bunch of JOINS on cols I list in the ON clause. I foolishly thought there was some more sophisticated comparing going on in the background based on the selection of fields in the USING clause. Nuts. I haven't used it much, thought it might be faster than JOINS or UNION for comparing fields. I have a hunch it aint, it just looks like a gussied up JOIN, at least as far as comparing cols.Thanks!Most people who drown do so in chest deep water. |
|
|
|
|
|
|
|