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.Net.Http; | |
namespace ConsoleApp18 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var client = new HttpClient(); |
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 ConvertTo-DataTable { # https://powersnippets.com/convertto-pson/ | |
[CmdletBinding()]Param( # Version 01.00.01, by iRon | |
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline = $true)] [PSObject[]]$Object, [HashTable]$ColumnType = @{} | |
) | |
$TypeCast = @{ | |
Guid = 'Guid', 'String' | |
DateTime = 'DateTime', 'String' | |
DateTimeOffset = 'DateTimeOffset', 'String' | |
Byte = 'Byte', 'Char', 'Int16', 'Int32', 'Int64', 'UInt16', 'UInt32', 'UInt64', 'Decimal', 'Single', 'Double', 'String', 'Boolean' | |
SByte = 'SByte', 'Int16', 'Int32', 'Int64', 'Decimal', 'Single', 'Double', 'String', 'Boolean' |
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
-- In the year 2020, we have self-driving cars, but MSSQL doesn't have the ability to cast to user-defined types. | |
-- This is an extremely hacky, slow, unsafe, untested, and completely unrecommended workaround. | |
declare @SystemTypeId tinyint, | |
@MaxLength smallint | |
select @SystemTypeId = system_type_id, @MaxLength = max_length from sys.types where name = 'your_user_defined_type_name'; | |
declare @TypeFullName sysname = type_name(@SystemTypeId) + (case | |
-- char, varchar | |
when @SystemTypeId in (167, 175) then '(' + cast(@MaxLength as varchar) + ')' |