Skip to content

Instantly share code, notes, and snippets.

@swasheck
swasheck / Inject GO
Created June 1, 2012 15:01
Inject GO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace file_edit
{
class Program
{
static void Main(string[] args)
@swasheck
swasheck / pg_hba.conf
Created June 1, 2012 19:52
pg_hba.conf
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# documentation for a complete description of this file. A short
# synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access. Records take one of these forms:
@swasheck
swasheck / group by with case
Created June 6, 2012 19:59
group by with case
declare @test table (
color_id integer,
color_name varchar(50)
);
insert into @test (color_id, color_name) values (1,'red');
insert into @test (color_id, color_name) values (1,'red');
insert into @test (color_id, color_name) values (1,'red');
insert into @test (color_id, color_name) values (2,'blue');
insert into @test (color_id, color_name) values (3,'yellow');
@swasheck
swasheck / TwoNulls.sql
Created June 12, 2012 19:33
twonulls sql
declare @test table (
id integer identity(0,1) not null,
dt1 datetime,
dt2 datetime
)
insert into @test (dt1) VALUES (dateadd(DAY, cast((rand() * 100) as int), getdate()))
insert into @test (dt1) VALUES (dateadd(DAY, cast((rand() * 100) as int), getdate()))
insert into @test (dt1) VALUES (dateadd(DAY, cast((rand() * 100) as int), getdate()))
insert into @test (dt1) VALUES (dateadd(DAY, cast((rand() * 100) as int), getdate()))
@swasheck
swasheck / gist:3295822
Created August 8, 2012 15:16
View Query
SELECT distinct
tbl1.col1 [Document ID],
tbl2.col2 [Description],
tbl1.col3 [Revision],
tbl1.col4 [Effective Date],
tbl4.col5 [Part#],
tbl5.col2 [Part Description]
FROM DB.dbo.table1 tbl1
INNER JOIN DB.dbo.table2 tbl2
ON tbl1.col1 = tbl2.col1
@swasheck
swasheck / gist:3295843
Created August 8, 2012 15:18
View Workaround
create view dbo.TheView
AS
select * from linkedserver.db.dbo.TheView
GO
@swasheck
swasheck / Makefile
Created October 2, 2012 21:42 — forked from peplin/Makefile
Installation script for PyLucene
# Makefile for building PyLucene
#
# Supported operating systems: Mac OS X, Linux and Windows.
# See INSTALL file for requirements.
# See jcc/INSTALL for information about --shared.
#
# Steps to build
# 1. Edit the sections below as documented
# 2. make
# 3. make install
DECLARE @CounterPrefix NVARCHAR(30)
SET @CounterPrefix = CASE
WHEN @@SERVICENAME = 'MSSQLSERVER'
THEN @CounterPrefix + ''
ELSE 'MSSQL$'+@@SERVICENAME+':'
END;
SELECT
server_name = @@SERVERNAME,
server_instance = @@SERVICENAME,
object_name,
@swasheck
swasheck / gist:6625242
Created September 19, 2013 15:30
Extended Event Issue
-- XE Definition
CREATE EVENT SESSION [page_splits] ON SERVER
ADD EVENT sqlos.wait_info(
ACTION (sqlos.task_time,sqlserver.sql_text,package0.collect_system_time)
WHERE ([sqlserver].[database_id]=(18))),
ADD EVENT sqlos.wait_info_external(
ACTION (sqlos.task_time,sqlserver.sql_text,package0.collect_system_time)
WHERE ([sqlserver].[database_id]=(18))),
ADD EVENT sqlserver.page_split(
ACTION(sqlos.task_time,sqlserver.sql_text,package0.collect_system_time)
@swasheck
swasheck / plan voodoo
Created December 18, 2013 18:10
top io queries with plan compile stats
SELECT
TOP(100)
collection_date = GETDATE(),
database_name = DB_NAME(CAST(pa.dbid AS INTEGER)),
database_name_exec = DB_NAME(CAST(pa.dbid_execute AS INTEGER)),
qs.total_worker_time,
qs.execution_count,
qs.sql_handle,
qs.plan_handle,
qs.creation_time,