Reputation: 3147
I am using SQL Server for my web application. How will I know that an insert query failed because the database server memory disk is already full
Upvotes: 0
Views: 545
Reputation: 5078
You can simulate this by disabling the auto-grow feature on the database (It's a checkbox in the database properties on the file tab) and filling up the database. The error will be the same.
ALTER DATABASE YourDatabase
MODIFY FILE (name='YourFile' MAXSIZE=50MB);
Upvotes: 2
Reputation: 1065
I suppose you can believe that if the disk is full the SQL server will return the error code :).
You can make your testing code think it is communicating with the SQL server but instead it will talk to some fake object of yours that will respond with the error codes you want to test.
There are frameworks that can help you. One of them is Rhino Mocks you can download from http://ayende.com
Upvotes: 1
Reputation: 8335
Check the error code you get back from SQL Server when you try to insert into the database.
With that error given back you can then decide what to do. (e.g. Try to insert again, Try to free up some memory on the server) Also if you havent already, place your Insert statement inside a Transaction so that you can rollback if an error occurs.
Upvotes: 1
Reputation: 1065
The error code you will get back will indicate that the disk is full: 1105 (primary filegroup full) or 9902 (log file full)
Upvotes: 4
Reputation: 11397
if you want to find you memory usage
exec sp_spaceused
This will give you how much memory you are used for particular database
Upvotes: 1