Conditional update or insert in one statement

  • I have a situation where I'm processing records on one table (Table A) and based on the existance of each record on another table (Table B), I either need to update the row on Table B or insert the row into Table B. We have SQL Server 2008, but I shouldn't use merge because we have clients who aren't on 2008 yet. Can someone please tell me how best to perform this?

    Thanks

  • Try read this:

    http://technet.microsoft.com/en-us/library/bb510625.aspx

    It gives an example of the code required to basically perform a merge without using the MERGE statement. It might assist you

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • I was struggling with knowing how to consecutively read Table A and update or insert it to Table B. The example they show without the merge, appears to me that it will do that. I will give it a try. Thanks so much!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply