urgent query

  • ok

  • IF EXISTS (SELECT 1 FROM SomeTable WHERE SomeKey = @SomeValue)

    UPDATE ...

    ELSE

    INSERT ...

    Edit: The question was (paraphrased)

    If I have a table and I want to check based on a key value, if there's a row in the table matching the key, update that row, otherwise insert the row.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • urgent? if you had read the chapter or listened to the lecture in class....

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (1/7/2009)


    urgent? if you had read the chapter or listened to the lecture in class....

    hehe ... You got that RIGHT!


    * Noel

  • Lowell (1/7/2009)


    if you had read the chapter or listened to the lecture in class....

    Yeah, probably.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hi

    Are you expecting all the possible answers to your post, so that you can frame your question based on this :w00t:

    Thanks -- Vj

    http://dotnetvj.blogspot.com

    http://oravj.blogspot.com

  • What was the question?

    Its gone away- I think hes edited it away or something...

    Im just curious...

  • Remember exactly, can't but think some like this:

    check if an item exists in the table, if yes update it, else insert it.

  • pcreddy9 (1/7/2009)


    ok

    Please don't edit your questions away. It just makes it confusing for everyone who reads it afterwards.

    It's also polite to let us know if the solutions worked or not.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 9 posts - 1 through 8 (of 8 total)

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