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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Best method to update/insert data

Author  Topic 

John Sourcer
Yak Posting Veteran

91 Posts

Posted - 2009-04-29 : 05:48:37
Hey Guru's,

I've read several topics on this subject but wanted to check with you first:


UPDATE mytable SET mycol = 'test' WHERE myid = 1

IF @@ROWCOUNT = 0
BEGIN
INSERT INTO mytable (mycol) VALUES ('test')

END


I am update/inserting from an OPENXML query with many records. Is this the best way?

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-04-29 : 08:37:06
Try following the first link in my signature, and restating your question with the data that is asked for. Answers will follow in short order. (or, once again, someone will answer before you get a chance.)

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL or How to sell Used Cars
For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -