DECLARE @DB_NAME varchar(1000) SELECT @DB_NAME = 'Northwind_DB' DECLARE @AllConnections TABLE( SPID INT, Status VARCHAR(MAX), LOGIN VARCHAR(MAX), HostName VARCHAR(MAX), BlkBy VARCHAR(MAX), DBName VARCHAR(MAX), Command VARCHAR(MAX), CPUTime INT, DiskIO INT, LastBatch VARCHAR(MAX), ProgramName VARCHAR(MAX), SPID_1 INT, REQUESTID INT ) INSERT INTO @AllConnections EXEC sp_who2 SELECT * FROM @AllConnections WHERE DBName = @DB_Name ORDER BY HostName
Tuesday, July 31, 2018
Get "exec sp_who2" into a table
Running sp_who2 will quickly display all connections to a SQL Server instance. Below is an enhancement to sp_who2 that allows database-specific connections.
ASP.NET MVC Scaffolding Template Files (T4)
The following is where you can find the T4 template files used by ASP.NET MVC Scaffolding:
Visual Studio 2015:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\
Visual Studio 2017:
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.visualstudio.web.codegenerators.mvc\
Visual Studio 2015:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\
Visual Studio 2017:
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.visualstudio.web.codegenerators.mvc\
Friday, July 27, 2018
Database Drop takes a long time when deleting backup history option is selected in SQL Server
Here's a workaround to speed up database drop. When there are a long history of backup in MSDB database, dropping a database with "Delete backup history" option could take a while.
Update statistics on MSDB tables and create an index for backupset table for [database_name] column.
/* Update statistics in [msdb] database */ USE msdb; GO UPDATE STATISTICS backupfile; GO UPDATE STATISTICS backupmediafamily; GO UPDATE STATISTICS backupmediaset; GO UPDATE STATISTICS backupset; GO UPDATE STATISTICS restorefile; GO UPDATE STATISTICS restorefilegroup; GO UPDATE STATISTICS restorehistory; GO /* Create an index on [backupset] table in [msdb] database for [database_name] column */ Create index IX_backupset_database_name on backupset(database_name); GO
Subscribe to:
Posts (Atom)