This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Which Folder we are looking in to it | |
$folderPath = "C:\Path\To\Your\Folder" | |
$oneMBF = (Get-Date).AddMonths(-1) | |
# Recurse On the folders | |
Get-ChildItem -Path $folderPath -Directory | ForEach-Object { | |
$folderName = $_.Name | |
$folderCreateDate = $_.CreationTime | |
# Do not delete topology an chk folder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT 'DROP STATISTICS ' | |
+ SCHEMA_NAME(ob.Schema_id) + '.' | |
+ OBJECT_NAME(s.object_id) + '.' + | |
s.name DropStatisticsStatement | |
FROM sys.stats s | |
INNER JOIN sys.Objects ob ON ob.Object_id = s.object_id | |
WHERE SCHEMA_NAME(ob.Schema_id) <> 'sys' | |
AND Auto_Created = 0 AND User_Created = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE LBS220 | |
DECLARE @TL VARCHAR(MAX) | |
DECLARE @TB VARBINARY(MAX) | |
DECLARE @DZERO INT | |
SELECT @TB= CONVERT(varbinary(MAX), LDATA) FROM LG_999_FIRMDOC where INFOREF=2 | |
PRINT @TB | |
SELECT @DZERO= CHARINDEX (CONVERT(VARCHAR(max), 0x00),CONVERT(VARCHAR(max), @TB) COLLATE Latin1_General_100_BIN2) | |
WHILE(@DZERO<>0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wevtutil el | Foreach-Object {wevtutil cl “$_”} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select top 10 schema_name(tab.schema_id) + '.' + tab.name as [table], cast(sum(spc.used_pages * 8)/1024.00 as numeric(36, 2)) as used_mb, cast(sum(spc.total_pages * 8)/1024.00 as numeric(36, 2)) as allocated_mb from sys.tables tab join sys.indexes ind on tab.object_id = ind.object_id join sys.partitions part on ind.object_id = part.object_id and ind.index_id = part.index_id join sys.allocation_units spc on part.partition_id = spc.container_id group by schema_name(tab.schema_id) + '.' + tab.name order by sum(spc.used_pages) desc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- You have to edit script for your temp db count :) | |
USE [tempdb] | |
GO | |
DBCC FREEPROCCACHE | |
DBCC DROPCLEANBUFFERS | |
DBCC FREESYSTEMCACHE ('ALL') | |
DBCC FREESESSIONCACHE | |
DBCC SHRINKFILE ('tempdev', 500) | |
DBCC SHRINKFILE ('temp2', 500) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @from int | |
declare @leap int | |
declare @to int | |
declare @datafile varchar(128) | |
declare @cmd varchar (512) | |
/*settings*/ | |
set @from = 200000 /*Current size in MB*/ | |
set @to = 180000 /*Goal size in MB*/ | |
set @datafile = 'TESTDB' /*Datafile name*/ | |
set @leap = 500 /*Size of leaps in MB*/ |