STATUS_NO_SAVEPOINT_WITH_OPEN_FILES (0xC0190048) Fix
Your database transaction can't create a savepoint because a file is open inside it. Close the file handle or restructure the transaction. Simple fix first.
The 30-Second Fix: Close the File Before the Savepoint
You're getting STATUS_NO_SAVEPOINT_WITH_OPEN_FILES (0xC0190048) because you're trying to create a savepoint while a file handle is still open inside the same transaction. SQL Server (or the underlying OS) won't let you do that — it's a safety check.
Quick fix: close the file handle before calling SAVE TRANSACTION.
-- Bad: file open, then savepoint
BEGIN TRANSACTION;
OPEN myFile FOR ... ; -- file handle stays open
SAVE TRANSACTION mySavepoint; -- boom: 0xC0190048
COMMIT;
-- Good: close file first
BEGIN TRANSACTION;
OPEN myFile FOR ... ;
CLOSE myFile; -- close the handle
SAVE TRANSACTION mySavepoint; -- works fine
COMMIT;If you need the file open beyond the savepoint, move the file operations outside the transaction. Savepoints aren't designed to work with open file handles.
The 5-Minute Fix: Restructure the Transaction
Sometimes you can't just close the file — maybe you're still reading from it or writing to it after the savepoint. In that case, restructure so the file operations happen outside the transaction scope.
Wrap the file work in a separate block, not inside the savepoint transaction.
-- Restructured: file outside transaction
DECLARE @fileData VARBINARY(MAX);
OPEN myFile FOR ... ;
READ myFile INTO @fileData;
CLOSE myFile;
BEGIN TRANSACTION;
INSERT INTO MyTable (Data) VALUES (@fileData);
SAVE TRANSACTION mySavepoint;
-- proceed with more SQL work
COMMIT;This pattern avoids the error entirely. I've seen this kill a nightly batch job at a logistics company — they were trying to read CSV files inside a long-running transaction with savepoints. Moving the file read before the transaction fixed it.
The Advanced Fix (15+ Minutes): Check for Implicit File Handles
If you're not explicitly opening files but still hitting this error, something is opening a file handle behind the scenes. Common culprits:
- Linked server queries that access file-based data sources (e.g., Excel, CSV via OPENROWSET).
- Extended stored procedures that read files (like
xp_cmdshelldoing file I/O). - SQLCLR code that opens file streams inside a transaction.
- FileTables or FILESTREAM operations inside a savepoint.
Run this query to see if there are open handles in your session:
SELECT * FROM sys.dm_exec_requests
WHERE session_id = @@SPID;
-- Check for pending I/O
SELECT * FROM sys.dm_io_pending_io_requests
WHERE session_id = @@SPID;If you find an open handle, trace back to the module or code that opened it. Use sys.dm_tran_session_transactions to confirm the transaction is still active.
Real-World Scenario
Had a client last month whose entire print queue died because of this — okay, not exactly print queue, but a document management system. Their stored procedure opened a file, read metadata, then tried to save a checkpoint inside the same transaction. Simple fix: close the file before the savepoint. But their dev had been fighting it for two days.
Pro tip: If you're using SAVE TRANSACTION for rollback points inside a large batch, consider using SET XACT_ABORT ON with try/catch blocks instead. Savepoints are fragile and this error is just one way they break.
Summary Table: Check Your Transaction Order
| Order | Result |
|---|---|
| OPEN file → SAVE TRANSACTION | Error 0xC0190048 |
| OPEN file → CLOSE file → SAVE TRANSACTION | Works |
| File work outside transaction → TRANSACTION → SAVE TRANSACTION | Works |
| Implicit file handle via linked server → SAVE TRANSACTION | Error (unless you close the handle) |
Bottom line: SQL Server won't let you create a savepoint when a file handle is open. Close it first, or move the file work outside the transaction. Start with the quick fix — most people find it's that simple.
Was this solution helpful?