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
Post a Comment