For example, if we have to insert person name and before inserting the person name we have to check Name availability in database. Then we can write one store procedure like this.
CREATE PROCEDURE InsertData
(
@firstName varchar(50),
@lastName varchar(50),
@age int
)
AS
/* SET NOCOUNT ON */
DECLARE @Count int
select @Count = Count(PersonID) from Person WHERE FirstName = @firstName
IF @Count = 0
BEGIN
INSERT INTO Person (FirstName, LastName, Age)
VALUES
(@firstName, @lastName, @age)
END
RETURN @Count
RETURN