简体   繁体   中英

Stored procedure without transaction

I have a stored procedure that performs calculations and stores a large amount of data in new tables, in another database. If anything goes wrong, I just drop the tables.

I've already set the recovery mode for this database as simple, as the data is available elsewhere. Is there anything else I can do in the stored procedure to limit writing to the transaction log or remove transactions entirely to speed up the process?

I suggest you that using SSIS package in order to convert data from one database to another database. in SSIS you can control converted data and can use balk insert. In buck insert mode you limit your database to write transaction logs completely.

It is impossible to completely eliminate transaction log from the equation in SQL Server.

You may try to check bulk logged recovery model in conjunction with bulk insert , but if your calculations are complex and cannot be expressed within a single select statement, it could be worth trying SSIS.

I ran into similar situations even while using SSIS where my staging database(s) kept logs more then 10 times the size of the actual data (on simple logging and using bulk insert). After lots of searching I have found that it is not feasable to prevent this from happening when doing large data operations like loading a datawarehouse. Instead it is easier to just clean up after you are done by shrinking the log.

dbcc shrinkfile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM