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 2000 Forums
 Transact-SQL (2000)
 help with sp

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2003-02-16 : 19:56:49

Just wondering if someone could lend me a hand on this one, I think its pretty straight forward. I'm a bit unsure of the syntax.

Basically, if a row is found that meets the first select statment, I then want to update that row. The select statement is sort of pseudo coded, the second @thumbID is not a typing mistake.

THanks alot!
mike123



CREATE PROCEDURE delete_photo
(
@userID int,
@thumbID int
)
AS SET NOCOUNT ON

DELETE tblThumbs WHERE userID = @userID and thumbID = @thumbID

IF
SELECT forum_Pic FROM tblUserDetails WHERE userID = @userID and thumbID = @thumbID = @thumbID

then

UPDATE tblUserDetails SET forum_Pic = '0' WHERE userID = @userID

GO

nr
SQLTeam MVY

12543 Posts

Posted - 2003-02-18 : 06:43:35
if exists (SELECT * FROM tblUserDetails WHERE userID = @userID and thumbID = @thumbID = @thumbID)
UPDATE tblUserDetails
SET forum_Pic = '0'
WHERE userID = @userID


You might want to put a transaction round all this.

Also not sure about the requirements here - looks a bit odd.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -