Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul White SQLKiwi

View GitHub Profile
View Obbish.cs
using Microsoft.SqlServer.Server;
using System.Collections.Specialized;
using System.Data.SqlTypes;
public partial class UserDefinedFunctions
{
[return: SqlFacet(MaxSize = 132, IsNullable = false, IsFixedLength = true)]
[SqlFunction(DataAccess = DataAccessKind.None, SystemDataAccess = SystemDataAccessKind.None, IsDeterministic = true, IsPrecise = true)]
public static byte[] NullableIntsToBinary
(
View Obbish Assembly Bits.sql
CREATE ASSEMBLY Obbish
FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300C13F9C9E0000000000000000E00022200B013000001200000006000000000000F6310000002000000040000000000010002000000002000004000000000000000600000000000000008000000002000000000000030060850000100000100000000010000010000000000000100000000000000000000000A33100004F000000004000008003000000000000000000000000000000000000006000000C00000004310000380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E74657874000000FC110000002000000012000000020000000000000000000000000000200000602E7273726300000080030000004000000004000000140000000000000000000000000000400000402E72656C6F6300000C0000000060000000020000001800000000000000000000000000004000004200
View HashCustomPerTable.cs
using Microsoft.SqlServer.Server;
using System.Collections.Specialized;
using System.Data.SqlTypes;
public partial class UserDefinedFunctions
{
[return: SqlFacet(MaxSize = 16, IsNullable = false, IsFixedLength = true)]
[SqlFunction(DataAccess = DataAccessKind.None, SystemDataAccess = SystemDataAccessKind.None, IsDeterministic = true, IsPrecise = true)]
public static unsafe byte[] HashCustomPerTable
(
View SafeSpooky.cs
using Microsoft.SqlServer.Server;
using System;
public partial class UserDefinedFunctions
{
private const ulong SpookyConst = 0xDEADBEEFDEADBEEF;
private const int BlockSize = 96;
private const int BufferSize = BlockSize * 2;
[return: SqlFacet(MaxSize = 16, IsFixedLength = true, IsNullable = false)]
[SqlFunction(DataAccess = DataAccessKind.None, SystemDataAccess = SystemDataAccessKind.None, IsDeterministic = true, IsPrecise = true)
View Spooky.cs
using Microsoft.SqlServer.Server;
using System.Data.HashFunction.SpookyHash;
using System.Data.SqlTypes;
public partial class UserDefinedFunctions
{
[SqlFunction
(
DataAccess = DataAccessKind.None,
SystemDataAccess = SystemDataAccessKind.None,