Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How to Create Store Procedure in SQL 2008
WhatsApp
Pintoo Yadav
Jan 07
2015
1.1
k
0
0
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
Up Next
How to Create Store Procedure in SQL 2008