SQL Transaction command Use

·       Transaction Command



This Command is use to
Perform Two  more commandExecute in one Time .
If Any insert queary is fail thanOther queary is Rollback .

Example :

CREATE PROCEDURE [dbo].[insertDatePROCE]
AS
BEGIN TRY
BEGIN TRAN
INSERT INTO test
(
studentname,
std,
IsActive,
CreationDate,
studentAddress
)
values
(
'BHAVYA',
6,
1,
GETDATE(),
'RAJKOT'
);
INSERT INTO test
(
studentname,
std,
IsActive,
CreationDate,
studentAddress
)
values
(
'JAYRAJ',
8,
1,
GETDATE(),
'RAJKOT'
);
INSERT INTO test
(
studentname,
std,
IsActive,
CreationDate,
studentAddress
)
values
(
'URVEE',
7,
1,
GETDATE(),
'AHEMDABAD'
);
COMMIT TRAN
END TRY

BEGIN CATCH
ROLLBACK TRAN
END CATCH

Comments

Popular posts from this blog

Search Record From Table Using jQuery in Asp.net core MVC

How To insert Radio Button Data in DataBase -- MVC

Toolbox Webparts Controls