sql management studio insert more than 1000 rows code example

Example: insert more than 1000 rows sql

BEGIN TRY
BEGIN TRANSACTION
-- Please enter 1000 rows for each insert
INSERT INTO OFBC_MD20_CC_Values (Column1, Column2, Column3, Column4, Column5, Cloumn6, Column7)
values('data1','data2','data3','data4','data5','data6','data7'),('data1','data2','data3','data4','data5','data6','data7')...   -- Till max 1000 rows
INSERT INTO OFBC_MD20_CC_Values (Column1, Column2, Column3, Column4, Column5, Cloumn6, Column7)
values('data1','data2','data3','data4','data5','data6','data7'),('data1','data2','data3','data4','data5','data6','data7')...... -- Till max 1000
INSERT INTO OFta3','data4','data5','data6','dBC_MD20_CC_Values (Column1, Column2, Column3, Column4, Column5, Cloumn6, Column7)
values('data1','data2','daata7'),('data1','data2','data3','data4','data5','data6','data7')...... -- Till max 1000
......Many time as needed

 

COMMIT TRANSACTION
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRAN -- RollBack in case of Error

DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY();

 

-- you can Raise ERROR with RAISEERROR() Statement including the details of the exception
THROW 51000, @ErrorMessage, 1
END CATCH

Tags:

Sql Example