January 7, 2009 at 1:17 pm
ok
January 7, 2009 at 1:31 pm
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
January 7, 2009 at 1:56 pm
urgent? if you had read the chapter or listened to the lecture in class....
Lowell
January 7, 2009 at 2:39 pm
Lowell (1/7/2009)
urgent? if you had read the chapter or listened to the lecture in class....
hehe ... You got that RIGHT!
* Noel
January 7, 2009 at 2:44 pm
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
January 8, 2009 at 10:23 am
Hi
Are you expecting all the possible answers to your post, so that you can frame your question based on this :w00t:
Thanks -- Vj
January 8, 2009 at 10:27 am
What was the question?
Its gone away- I think hes edited it away or something...
Im just curious...
January 8, 2009 at 10:42 am
Remember exactly, can't but think some like this:
check if an item exists in the table, if yes update it, else insert it.
January 8, 2009 at 11:06 am
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
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply