how to write a if else statement to insert query for showing the error in stored procedure
below is my stored procedure.I want to show a error message when already inserted student_id is insert again..Student_id is primary key so its show error in my code but i dono how to get that error and show ....how to do friends plz help me.....
ALTER PROCEDURE [dbo].[spinsertstudentapplication]
-- Add the parameters for the stored procedure here
@Student_id nvarchar(50),
@Select_Country nvarchar(50),
@Select_State nvarchar(50),
@Select_Franchise nvarchar(50),
@Select_Sensei nvarchar(50),
@Enter_Student_Name nvarchar(50),
@Enter_Student_Address nvarchar(50),
@Students_Father_Name nvarchar(50),
@Student_DOB datetime,
@Gender bit,
@Group nvarchar(50),
@Enter_Kyu nvarchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into StudentApplication(Student_id,Select_Country,Select_State,Select_Franchise,Select_Sensei,Enter_Student_Name,Enter_Student_Address,Students_Father_Name,Student_DOB,Gender,[Group],Enter_Kyu)values(@Student_id,@Select_Country,@Select_State,@Select_Franchise,@Select_Sensei,@Enter_Student_Name,@Enter_Student_Address,@Students_Father_Name,@Student_DOB,@Gender,@Group,@Enter_Kyu)
END