I want to create a procedure to update a table. It takes number of input parameters(one of them is the @pID) and updates four columns which have the pID=@pID and only one of these four columns can be updated if the value of another column='F' in addition to pID=@pID. How can I do this?
This is what I've got so far

CREATE PROCEDURE ABC (
@pID
@A INT,
@B CHAR,
@C CHAR,
@D VARCHAR)
AS
update EEE
set A=@A,
      B=@B,
      C=@C
WHERE pID=@pID

update EEE
set D=@D
Where pID=@pID AND G='T'

Recommended Answers

All 4 Replies

It looks like what you have is correct. It makes no sense whatsoever but it seems functional.

the code which u ve written is correct for stored procedure, i dont really understand wats ur problem is....

Thanks a lot. There was an error but I got it work.

You're welcome even though we didn't do much :)

Please mark this thread as solved since you have found a solution to your problem and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.