Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate SQL Server database going down

I've written an application that connects to a system over the network and logs events from that system to a SQL Server database.

I need to test the behaviour of the application when the SQL Server goes down. Is there a way to Kill just the one Database on a SQL Server system without affecting the others?

If not is there a way to simulate the SQL Server going down.

It shouldn't matter but the app is written in Java.

like image 419
Omar Kooheji Avatar asked Aug 26 '10 10:08

Omar Kooheji


2 Answers

You can use sqlcmd to set the database in single-user mode or detach the database using T-SQL. This will simulate the database going offline in a controlled fashion, but not simulate the server going down in an uncontrolled fashion, which perhaps could be more useful.

like image 67
bzlm Avatar answered Sep 24 '22 06:09

bzlm


Extending @bzlm's answer:

USE master
GO
ALTER DATABASE YourDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
like image 31
abatishchev Avatar answered Sep 22 '22 06:09

abatishchev