Skip to content

Instantly share code, notes, and snippets.

View DanielLoth's full-sized avatar

Daniel Loth DanielLoth

View GitHub Profile
@DanielLoth
DanielLoth / SQL Server data pivot (rows to columns).sql
Last active November 30, 2017 07:14
SQL Server data pivot (rows to columns)
-- Based on this article: http://modern-sql.com/use-case/pivot
set nocount on
declare @Table table (
TableName char(20),
AttributeName char(20),
AttributeValue char(20),
-- Mandatory: Each attribute must appear precisely once for each element.
@DanielLoth
DanielLoth / gist:2aaeac480cb9f7d09d9d9c1af5de5218
Created January 10, 2018 00:23
dotnet core project generation
dotnet new mvc -o MyProject
cd MyProject
REM CodeGenerators.Mvc added as package
dotnet add package "Microsoft.VisualStudio.Web.CodeGeneration.Design"
dotnet add package "Microsoft.VisualStudio.Web.CodeGenerators.Mvc"
REM CodeGeneration.Tools added as reference (not package) as it is tooling.
dotnet add reference "Microsoft.VisualStudio.Web.CodeGeneration.Tools"
@DanielLoth
DanielLoth / 0 - T-SQL auditing with triggers.sql
Last active January 11, 2018 12:15
T-SQL auditing with triggers
----------------------------------------------------------------------------------------------------
-- AUDITING WITH TRIGGERS
-- Written by Daniel Loth
----------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Populate a numbers table
--------------------------------------------------------------------------------
drop table if exists Number
go
@DanielLoth
DanielLoth / On negotiating salary
Last active January 12, 2018 14:24
On negotiating salary
# Negotiating salary
https://www.reddit.com/r/personalfinance/comments/7psra0/reminder_never_tell_hr_how_much_you_make_or_are/
-----
Reddit user sadakxp (https://www.reddit.com/user/sadakxp) made this post:
Here's why this is not fair and what you should do about it, as a person interviewing.
@DanielLoth
DanielLoth / 1 - SharePoint table PIVOT.sql
Last active January 22, 2018 03:59
SharePoint table PIVOT
with CommaSeparatedColNames as (
select
TABLE_NAME,
DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH,
NUMERIC_PRECISION,
NUMERIC_SCALE,
ListIdColName,
ColNameList,
TPrefixedColNameList,
@DanielLoth
DanielLoth / sql.sql
Created April 11, 2019 05:50
Get SQL object code
--select text from Payroll.sys.syscomments where id = 55086;
select * from sys.sql_modules where [object_id] = 55086;
select value from STRING_SPLIT(
(select [definition] from Payroll.sys.sql_modules where [object_id] = 55086), char(10));
select value from STRING_SPLIT(
(select replace([definition], char(13), '') from Payroll.sys.sql_modules where [object_id] = 55086), char(10));
@DanielLoth
DanielLoth / git commands
Created March 19, 2021 05:06
Git stuff
# Assumption: Your remotes are configured as 'origin' (for personal fork) and 'upstream' (for shared git repo).
# First, make sure your local workspace is clean
git status
# If it isn't, either create a WIP branch OR stash your changes
# WIP branch:
git checkout -b my-current-WIP-19-mar-2021
git add *
git commit -m 'WIP'
@DanielLoth
DanielLoth / gist:6a8777dd978b8d00dbe5d6fa880fed59
Created June 25, 2021 13:33
comp.theory.database 2021-06-25
create procedure dbo.AddAttendance_tr
@OrganisationId int,
@PersonId int,
@AttendanceDate date
as
set nocount on;
------------------------------------------------------------
-- Validation block