Disabling SQL Server Agent Jobs

USE MSDB;
GO
UPDATE MSDB.dbo.sysjobs
SET Enabled = 0
WHERE Enabled = 1;
GO

Advertisements

Powershell: switch from normal mode to administrator mode

Start-Process powershell -Verb runAs

SQL databases recovery model

SELECT name, recovery_model_desc
FROM sys.databases

GO

Send Email with PS

Send-MailMessage -From “email address” -To “email address” -Subject “Test email” -Body “Test” -SmtpServer “SMTP server address”

Set offline database

ALTER DATABASE <dbasename> SET OFFLINE WITH
ROLLBACK IMMEDIATE
GO

How to force drop database in SQL

USE master;
ALTER DATABASE [databasename] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [databasename] ;

Cannot see a SQL Configuration Manager

sqlservermanager11.msc