This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using System.Xml; | |
using System.Xml.Linq; | |
namespace GithubWikiDoc | |
{ |
This file contains 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 | |
t.NAME AS TableName, | |
i.name as indexName, | |
sum(p.rows) as RowCounts, | |
sum(a.total_pages) as TotalPages, | |
sum(a.used_pages) as UsedPages, | |
sum(a.data_pages) as DataPages, | |
(sum(a.total_pages) * 8) / 1024 as TotalSpaceMB, | |
(sum(a.used_pages) * 8) / 1024 as UsedSpaceMB, | |
(sum(a.data_pages) * 8) / 1024 as DataSpaceMB |
This file contains 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 @SearchStr nvarchar(100) | |
SET @SearchStr = 'Text to find' | |
-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved. | |
-- Purpose: To search all columns of all tables for a given search string | |
-- Written by: Narayana Vyas Kondreddi | |
-- Site: http://vyaskn.tripod.com | |
-- Tested on: SQL Server 7.0 and SQL Server 2000 | |
-- Date modified: 28th July 2002 22:50 GMT |
This file contains 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 | |
database_name = DB_NAME(database_id) | |
, log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) | |
, row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) | |
, total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2)) | |
FROM sys.master_files WITH(NOWAIT) | |
GROUP BY database_id | |
ORDER BY total_size_mb |
This file contains 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
function AddItemProperties($item, $properties, $output) | |
{ | |
if($item -ne $null) | |
{ | |
foreach($property in $properties) | |
{ | |
$propertyHash =$property -as [hashtable] | |
if($propertyHash -ne $null) | |
{ | |
$hashName=$propertyHash["name"] -as [string] |
This file contains 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
-- disable referential integrity | |
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' | |
GO | |
EXEC sp_MSForEachTable 'DELETE FROM ?' | |
GO | |
-- enable referential integrity again | |
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL' | |
GO |
This file contains 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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
public static class PowershellLinqSupport | |
{ | |
/// <example>[PowershellLinqSupport]::Range(1, 4)</example> | |
public static PowershellLinqSupport<int> Range(int start, int count) |
This file contains 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
function Using-Object | |
{ | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[AllowEmptyString()] | |
[AllowEmptyCollection()] | |
[AllowNull()] | |
[Object] | |
$InputObject, |
This file contains 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
public static IEnumerable<TResult> FullJoin<TOuter, TInner, TKey, TResult>( | |
this IEnumerable<TOuter> outer, | |
IEnumerable<TInner> inner, | |
Func<TOuter, TKey> outerKeySelector, | |
Func<TInner, TKey> innerKeySelector, | |
Func<TOuter, TInner, TResult> resultSelector) | |
{ | |
return from key in outer.Select(outerKeySelector).Union(inner.Select(innerKeySelector)) | |
join outerItem in outer on key equals outerKeySelector(outerItem) into outerGroup | |
from outerItem in outerGroup.DefaultIfEmpty() |
This file contains 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
public static IEnumerable<TResult> Join<TOuter, TInner, TResult>( | |
this IEnumerable<TOuter> outer, | |
IEnumerable<TInner> inner, | |
Func<TOuter, TInner, bool> condition, | |
Func<TOuter, TInner, TResult> resultSelector) | |
{ | |
return from outerItem in outer | |
from innerItem in inner | |
where condition(outerItem, innerItem) | |
select resultSelector(outerItem, innerItem); |
OlderNewer