Using Store Procedure for add data to table is very important
and all developer like use it. because it provide fast and
good process when you add data to table. this is a example
and code for Add data to table.
USE [SecDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[tbl_Group_AddData]
@ID int,
@Name varchar(50),
@Sex int,
@SMS varchar(100) Output
As
If Exists(Select * From tbl_Name Where ID=@ID)
Begin
Set @SMS='Data exist already. Please Change!'
End
Else
Begin
Insert Into tbl_Group
(
ID,
Name,
Sex
)
Values
(
@ID,
@Name,
@Sex
)
Set @SMS='Insert data successful'
End
If can show message when insert successful and
when have data already.
No comments:
Post a Comment