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 |
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-07-30 : 10:33:16
|
Hi:I am trying to write a stored procedure that when passed a name, value it will1. update the record if the name exists2. create a new record if it doesnthow would i do this? |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-07-30 : 10:39:48
|
IF exists(select * from table1 where [name] = @name)BEGIN "UPDATE CODE HERE"ENDELSEBEGIN "INSERT CODE HERE"ENDJim |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-30 : 10:40:32
|
ThisUPDATE ....IF @@ROWCOUNT = 0 INSERT ...or thisif exists (select * from table1 where name = @param) updateelse insert E 12°55'05.25"N 56°04'39.16" |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-30 : 10:41:02
|
 E 12°55'05.25"N 56°04'39.16" |
 |
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-07-30 : 10:52:06
|
fast answer thanks |
 |
|
Kristen
Test
22859 Posts |
|
|
|
|