TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Create Store Procedure in SQL 2008
Pintoo Yadav
Jan 07
2015
Code
1.1
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
use golivecode_com_
/****** Object: StoredProcedure [dbo].[register_insert] Script
Date
: 10/04/2014 13:24:25 ******/
SET
ANSI_NULLS
ON
GO
SET
QUOTED_IDENTIFIER
ON
GO
alter
Procedure
[dbo].[register_insert]
@reg_id
bigint
,
@
name
varchar
(30),
--@sirname varchar(30),
@mobile
varchar
(50),
--@user_id varchar(10),
@
password
varchar
(50),
@post
varchar
(50),
@email
varchar
(40),
@companyname
varchar
(30),
@usertype
varchar
(8),
@Actions
int
As
BEGIN
IF( @Actions = 1 )
-- INSERT
BEGIN
if
not
exists(
Select
1
from
golivecode.register_mst
where
CONVERT
(
varchar
,
name
)=
CONVERT
(
varchar
,@
name
))
begin
INSERT
INTO
golivecode.register_mst(
name
,Email,
password
,mobile,companyname,usertype,post,Actions)
VALUES
(@
name
,@Email,@
password
,@mobile,@companyname,@usertype,@post,@Actions)
IF ( @@ERROR > 0 )
BEGIN
ROLLBACK
TRAN
RETURN
(0)
END
RETURN
(1)
end
ELSE
RAISERROR(
'Validation Failed: User ID already Exists'
,16,1)
BEGIN
RETURN
(2)
END
END
ELSE
IF( @Actions = 2 )
-- UPDATE
BEGIN
if
not
exists(
Select
1
from
register_mst
where
CONVERT
(
varchar
,
name
)=
CONVERT
(
varchar
,@
name
))
begin
-- UPDATE register_mst SET firstname=@firstname,lastname= @lastname,Email=@Email,password=@password,
-- gender= @gender,dob= @dob,usertype= @usertype,Actions=@Actions
-- WHERE cust_id = @cust_id
If(@@ERROR> 0)
BEGIN
ROLLBACK
TRAN
RETURN
(0)
END
RETURN
(1)
end
ELSE
RAISERROR(
'Validation Failed: User Name already Exists'
,16,1)
BEGIN
RETURN
(2)
END
END
END
SQL
Store Procedure
Create Store Procedure in SQL