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 |
|
new_bees
Starting Member
27 Posts |
Posted - 2008-05-24 : 21:01:35
|
| Hi guys,Can I do an Insert and Update at the same time?Insert code:ALTER PROCEDURE [dbo].[AddComments]@ID int,@Author varchar(20),@Email varchar(50),@Comments varchar(200)ASdeclare @ErrorCode intSET NOCOUNT ONINSERT INTO COMMENTS_RECIPE (ID,AUTHOR,EMAIL,COMMENTS) VALUES( @ID, @Author, @Email, @Comments )set @ErrorCode = @@errorSET NOCOUNT OFFreturn @ErrorCodeUpdate code:Update Recipes SET TOTAL_COMMENTS = TOTAL_COMMENTS + 1 where ID = @IDHow do I place the two in stored procedure. Sorry guys for asking this silly question. I'm still learning.Update Recipes SET TOTAL_COMMENTS = TOTAL_COMMENTS + 1 where ID = @ID |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-05-24 : 22:31:29
|
| You can put them in single sp, check 'CREATE PROCEDURE (Transact-SQL)' in books online for samples. |
 |
|
|
new_bees
Starting Member
27 Posts |
Posted - 2008-05-28 : 14:59:54
|
| Thanks guys,I just need to place a semi colon to the end of the first statement. |
 |
|
|
|
|
|