Sql-server – Does MSSQL Server need more space than the size of the data itself for importing? How much more

sql serversql-server-2012

Does MSSQL Server need more space than the size of the data itself for importing? How much more? How to tell?

Recently tried copying data into MSSQL server (2012)

Microsoft SQL Server Management Studio          11.0.3156.0
Microsoft Analysis Services Client Tools        11.0.3130.0
Microsoft Data Access Components (MDAC)         6.2.9200.16384
Microsoft MSXML                                 3.0 5.0 6.0 
Microsoft Internet Explorer                     9.10.9200.22387
Microsoft .NET Framework                        4.0.30319.18449
Operating System                                6.2.9200

using BCP and was seeing errors like

Error = [Microsoft][ODBC Driver17 for SQL Server][SQL Server]The transaction log for database 'EpicShd' is full due to 'CHECKPOINT'.

and

Error = [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The transaction log for database 'EpicShd' is full due to 'ACTIVE_TRANSACTION'.

When looking at the DB itself, it threw…

Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details. (Microsoft SQL Server, Error: 945)

For context, the total size of the data (at least the TSVs that BCP was copying in) was ~10G, while the total storage space on the DB server was 28G, so I would think there would not be a problem. I am bringing in multiple tables each being 500MB-1GB and doing it in set of 1-2 at a time.

Does copying data into MSSQL server take more space than the data itself? How much (temporary storage)? How can I tell (not much experience with DBA)?

Best Answer

First, check what is your recovery mode, having log errors like the ones you pasted are often related to recovery mode Full. Check it using following query:

select name, recovery_model_desc from sys.databases

If it is anything but simple, every bit of data is saved multiple times, first in data file and in the log file. If you have staging tables, all inserts to these tales are preserved in logs too, even if you delete the data from the table itself.
It is needed for the possible recovery to point in time.
In this scenario you need to switch recovery mode to Simple and then db will purge logs automatically.