Skip to content

Instantly share code, notes, and snippets.

View yorek's full-sized avatar
:octocat:
Working from home

Davide Mauri yorek

:octocat:
Working from home
View GitHub Profile
@yorek
yorek / get-sql-supported-collations
Last active August 29, 2015 14:03
Show the list of supported collations in SQL Server
SELECT
[name]
, [CodePage] = COLLATIONPROPERTY([name], 'CodePage')
, [LCID] = COLLATIONPROPERTY([name], 'LCID')
, [ComparisonStyle] = COLLATIONPROPERTY([name], 'ComparisonStyle')
, [Version] = COLLATIONPROPERTY([name], 'Version')
, [description]
FROM
::fn_helpcollations();
@yorek
yorek / get-ssas-server-info
Created July 9, 2014 11:49
Detects Analysis Services Version and Edition
[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") | Out-Null
$serverName = "localhost"
$server = New-Object Microsoft.AnalysisServices.Server
$server.Connect($serverName)
Write-Output ("`nServer: {0}`nEdition: {1}`nBuild: {2}" -f $server.Name, $server.Edition, $server.Version)
@yorek
yorek / get-sql-table-size
Last active August 29, 2015 14:04
Return table (split by index and partition) size and row count
DECLARE @tableNamePattern SYSNAME = '%'
SELECT
t.name,
p.index_id,
p.partition_number,
[rows] = format(p.row_count, '#,0'),
used_space = format(p.used_page_count * 8 / 1024., '#,0 MB'),
reserved_space = format(p.reserved_page_count * 8 / 1024., '#,0 MB')
FROM
@yorek
yorek / get-wait-stats
Created August 25, 2014 12:22
Load and shows to top 25 highest wait stats taken in a period of 1 minute
if (object_id('tempdb..#t1') is not null) drop table #1
if (object_id('tempdb..#t2') is not null) drop table #2
go
select sample_date = sysdatetime(), * into #t1 from sys.dm_os_wait_stats
waitfor delay '00:00:01'
select sample_date = sysdatetime(), * into #t2 from sys.dm_os_wait_stats
go
select top 25
@yorek
yorek / add-new-tabular-partition
Last active April 26, 2022 01:42
Powershell script to add and process a new SSAS Tabular partition
# Load Assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") >$NULL
# Connect to Tabular SSAS
$srv = New-Object Microsoft.AnalysisServices.Server
$srv.connect("localhost\TABULAR")
# Point to a specific Database
$db = $srv.Databases.FindByName("DatabaseName");
@yorek
yorek / gist:77eca81a1ab4e0f51dea
Created April 8, 2015 15:58
Powershell script to add and process a new SSAS Multidimensional partition (mimicking subpartitions usage)
# Load Assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") >$NULL
# Connect to Tabular SSAS
$srv = New-Object Microsoft.AnalysisServices.Server
$srv.connect("localhost")
# Point to a specific Database
$db = $srv.Databases.FindByName("MyDatabase");
@yorek
yorek / centos-set-keyboard
Last active August 29, 2015 14:23
Set keyboard map to Italian in CentOS 6.6
loadkeys it
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@yorek
yorek / get-r-home.sql
Last active April 13, 2016 11:55
Get installation directory for MRO in SQL Server 2016
execute sp_execute_external_script
@language = N'R',
@script = N'OutputDataSet <- data.frame(R.home());'
with result sets (([R.home()] nvarchar(max) not null));
@yorek
yorek / azure-functions-save-form-data-to-sql-azure.csx
Last active July 6, 2018 12:11
Save JSON data into SQL Azure using Azure Functions
#r "Newtonsoft.Json"
using System;
using System.Net;
using System.Net.Mail;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Dapper;
using Newtonsoft.Json;