Wednesday 7 September 2011

How to Check the Table if the Record Exist in Table or Not


CREATE PROCEDURE [dbo].[uspInst_Addupdate]
(
@InstId int,
@Inst varchar(50),
)
AS
BEGIN
IF @InstId=0
BEGIN
IF NOT EXISTS(SELECT * FROM InstMaster WHERE Inst= @Inst)
INSERT INTO genInstituteMaster(Inst) VALUES(@Inst)
END
ELSE
BEGIN
UPDATE InstMaster
SET Inst= @Inst WHERE (Inst= @Inst)
END
END 

No comments:

Post a Comment