I want to know how can I use UPSERT or in other words UPDATE if records exists Else enter new record operation in SQL Server using one statement?  This example shows the ways of achieving this in Oracle  But it uses Dual table for it which doesn't exists in SQL Server.  So, Any SQL Server Alternatives (No Stored procedures) please ?
Assume a table structure of MyTable(KEY, datafield1, datafield2...).  Often I want to either update an existing record, or insert a new record if it doesn't exist.  Essentially:  IF (key exists)   run update command ELSE   run insert command   What's the best performing way to write this?
Create a shortcut for URL? string str1 = "12345ABC...\\...ABC100000";   // Hypothetically huge string of 100000 + Unicode Chars  str1 = str1.Replace("1", string.Empty);  str1 = str1.Replace("22", string.Empty);  str1 = str1.Replace("656", string.Empty);  str1 = str1.Replace("77ABC", string.Empty);   // ...  this replace anti-pattern might happen with upto 50 consecutive lines of code.   str1 = str1.Replace("ABCDEFGHIJD", string.Empty);   I have inherited some code that does the same as the snippet above. It takes a huge string and replaces (removes) constant smaller strings from the large string.  I believe this is a very memory intensive process given that new large immutable strings are being allocated in memory for each replace, awaiting death via the GC.  1. What is the fastest way of replacing these values, ignoring memory concerns?  2. What is the most memory efficient way of achieving the same result?  I am hoping that these are the same answer!  Practical solutions that fit somewhere in between these goals are also appreciated.  Assumptions:    All replacements are constant and known in advance Underlying characters do contain some unicode [non-ascii] chars How to prove that $A_5$ has no subgroup of order 30? I need to show that $A_5$ has no subgroup of order 30. Any ideas? Combinatorial proof of summation of $\sum\limits_{k = 0}^n {n \choose k}^2= {2n \choose n}$ Subdivision surface modifier creates pinching at corners I've only been 3D modelling for a few days now, so this may just be a newbie mistake:  However, because this model is for use in a game I am trying to stay away from proximity loops for performance reasons. Instead, I have used edge creases to maintain the structure of the model. It has led to certain vertices not being affected by the subsurf modifier, causing undesirable lighting at high subsurf levels.  Manually moving each point in a bit seems kind of sloppy but I'm not too sure what the best way to go about this is.  If any more information is needed I'll give what I can, thanks in advance :) How can Finder empty Trash more quickly than "rm -rf /Volumes/Foo/.Trashes/501/*"? The "Trash" of a 16-GB usb2 flash drive had 3.4-GB of data. I emptied it as such:     $ cd /Volumes/FooDrive/.Trashes/501   $ rm -rf *   This took over 5-seconds. That seemed pretty long. So, as a test I just decided to empty the Trash of all of my drives via Finder. Other drives: 2-TB usb3 500-GB usb2 16-GB usb2 250-GB ssd  I measured the size of the Trash as such:       $ du -ch /Volumes/WhateverDrive/.Trashes   There was 15-GB in the Trash of the 500-GB drive, and 5-GB in the Trash of my other 16-GB flash drive. I didn't measure the other drives.  Finder appeared to take much less than 5-seconds to empty the Trash for all those drives.   Does Finder really empty the Trash so much more quickly than /bin/rm? How?   Does Finder just make the "clicking sound" (signaling the trash is empty) before the Trash on all the drives is really empty? Checking if a worksheet-based checkbox is checked hotel occupancy counting problem The multiple-choice question:  A hotel has four vacant rooms. Each room can accommodate a maximum of four people. In how many different ways can six people be accommodated in the four rooms? (A) 4020 (B) 4068 (C) 4080 (D) 4096.  My attempt:  If there were no 'four person' constraint, the six people could be accommodated in $4^6=4096$ ways. however, this number includes combinations with 5 or 6 people in one room, which should be excluded.  If one room has 5 occupants, one other room has 1 occupant. The number of '1,5' combinations is ${{4} \choose {2}}$=12. If one room has 6 occupants, the other three rooms have no occupants, and there are four such combinations.  I believe the answer should be $4096-12-4=4080$, but am not confident. I'd be grateful for any comments on my attempt. What Sci-Fi book (1987 or older) had Aliens conquer earth and made Humans their slaves? I have been trying to recall the title of a book I read about 25 years ago (1987), I have tried to find it again a couple of times over the years without any luck.    The story takes place on earth, which has been invaded and conquered by aliens.  The humans have become servants or slaves.  One of the primary human characters is the human servant of an alien leader.  If I remember correctly, the aliens are much bigger than humans, I keep thinking of horses or elephants for some reason with regard to the aliens.  At the end, somehow the human slaves have forced the aliens to abandon their conquest of earth, but I don't remember exactly why.  I think it was something to do with simply refusing to be obedient, which the aliens could not comprehend, but I'm not sure about that.  I think the book ends with the alien leader (and the rest of the aliens) blasting off from earth in a rocket.  Does anyone recognize what book I'm referring to?  Thanks for any help! Prove p-adic valuation is completely additive for prime p Can I set max_retries for requests.request? The interaction of TeX and Lua can be quite delicate at times.  While the former has category codes and tokens, the latter has escape sequences and datatypes.  Mixing the disparate concepts of these two worlds can lead to unexpected behaviour which favours common errors, known as gotchas. In the community wiki answer below you can find an overview of the common mistakes that people make when getting to grips with LuaTeX. How to disable Ctrl+Shift+U? Map from real numbers to real numbers as abelian groups Compiling a document with PGFplots processing only every x-th data point? Why are date-based hats awarded too early? In The Dark Knight Rises, at the beginning of the film Bane kidnapped a guy from the plane, then he drew blood from the guy he kidnapped. And then throughout the movie I didn't see any news regarding this kidnap scene. But, before the end of the movie we find out that the guy kidnapped by Bane was Dr Pavel. Bane needed him to convert the fusion project into a nuclear bomb and Dr Pavel was the only guy who could have done it.   But I don't understand, why did he draw blood from Dr Pavel? Find highest level of a hierarchical field: with vs without CTEs Hyperref - Token not allowed Possible Duplicate:          The following code:  \subsection{The classes $\mathcal{L}(\gamma)$}   generates the errors:  Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref)                removing `math shift' on input line 1938.   Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref)                removing `\gamma' on input line 1938.   Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref)                removing `math shift' on input line 1938.   What do I have to do to keep \gamma in the subsection, so that it is also listed in the table of contents? I want to enter the following folder in the terminal:  Milano, Torino (Jan)-Compressed   How should I write the command cd to enter this directory?  Spaces and several other special characters like \, *, ), ( and ? cause problems when I try to use them in the command line or scripts, e.g.:    $ cd space dir bash: cd: space: No such file or directory  $ cat space file cat: space: No such file or directory cat: file: No such file or directory  $ cat ( bash: syntax error near unexpected token `newline'  $ echo content &gt;\ &gt; ^C  $ ls ? (  )  *  ?  \   How do I enter file or directory names that contain special characters in the terminal in general?