Skip to content

Instantly share code, notes, and snippets.

View karoltheguy's full-sized avatar

Carol Ouellet karoltheguy

View GitHub Profile
@karoltheguy
karoltheguy / cross apply xml columns.sql
Last active November 30, 2017 00:01
Read from XML column (varchar type)
SELECT
CONVERT(varchar(19), t.completed AT TIME ZONE 'UTC' AT TIME ZONE 'US Eastern Standard Time') AS 'Completed'
,m.n.value('./@value', 'varchar(100)') AS One_Bill_Account_Number
,p.n.value('./@value', 'varchar(100)') AS Suspension_Start_Date
,o.n.value('./@value', 'varchat(100)') AS Suspension_End_Date
FROM (SELECT status, completed, queueident, loaded, CAST(data AS xml) AS data FROM BPAWorkQueueItem)t
CROSS APPLY t.data.nodes('/collection/row/field[./@name="One Bill Account Number"]')m(n)
CROSS APPLY t.data.nodes('/collection/row/field[./@name="Suspension Start Date"]')p(n)
CROSS APPLY t.data.nodes('/collection/row/field[./@name="Suspension End Date"]')o(n)
@karoltheguy
karoltheguy / exporttotext.sql
Created November 8, 2017 17:27
Export Column of text into individual files
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'xp_cmdshell',1;
RECONFIGURE
GO
CREATE TABLE TempProcessStore ([RowNo] [smallint] identity (1, 1)
,[name] nvarchar(128)
@karoltheguy
karoltheguy / forloop.bat
Last active May 8, 2024 12:40
Batch file for loop csv
@for /F "tokens=1,2,3 skip=1 delims=," %%A in (test.txt) do (
@echo I am at %%A using login %%B:%%C
)
@karoltheguy
karoltheguy / CreateHTMLTable
Created May 24, 2017 22:03
Make HTML table with SQL result
CREATE FUNCTION dbo.CreateHTMLTable(@SelectForXmlRawElementsXsinil XML)
RETURNS XML
AS
BEGIN
RETURN
(
SELECT
@SelectForXmlRawElementsXsinil.query('let $first:=/row[1]
return
@karoltheguy
karoltheguy / SplitString
Last active May 9, 2017 16:31
SQL Split string function
CREATE FUNCTION [dbo].[SplitString]
(
@List NVARCHAR(MAX),
@Delim VARCHAR(255)
)
RETURNS TABLE
AS
RETURN ( SELECT [Value] FROM
(
SELECT
@karoltheguy
karoltheguy / IsDaylightSavingTime
Created April 21, 2017 17:26
Determine if given date is within DST clock shift - SQL Scalar Function
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Carol Ouellet
-- Create date: 2017-04-21
-- Description: Determine if given date is within DST clock shift
-- =============================================
CREATE FUNCTION IsDaylightSavingTime
@karoltheguy
karoltheguy / ObservableDictionary.cs
Created March 3, 2017 17:34
Observable Dictionary
public class ObservableDictionary<TKey, TValue> : IDictionary<TKey, TValue>, INotifyCollectionChanged, INotifyPropertyChanged
{
private const string CountString = "Count";
private const string IndexerName = "Item[]";
private const string KeysName = "Keys";
private const string ValuesName = "Values";
private IDictionary<TKey, TValue> _Dictionary;
protected IDictionary<TKey, TValue> Dictionary
{
@karoltheguy
karoltheguy / gist:b3fde88c627b66b749c6080b236bcd51
Created February 15, 2017 20:41
Count all lines of code using powershell
(dir -exclude *.g.cs,*.i.cs,*.designer.cs,assemblyinfo.cs,app.* -include *.cs,*.xaml -recurse | select-string .).Count
//Missing exclusion of empty lines and comments(?)
@karoltheguy
karoltheguy / Program.cs
Last active February 1, 2017 19:08
Start Citrix Session with reference wfica.ocx(not embedded interop)
using System;
using System.Threading;
using WFICALib;
class Program
{
public static AutoResetEvent onLogonResetEvent = null;
/// This program demo's the basic of launching and ICO session from within an application.
static void Main(string[] args)
@karoltheguy
karoltheguy / module1
Last active August 29, 2015 14:17
Mass Auto Reply Outlook Macro
Sub SendReply(Item As Outlook.MailItem)
Dim strRecip As String
Dim Recipient As Outlook.Recipient
Dim objMsg As MailItem
'Save a template with a the content you want to reply and the CC addresses if needed, nothing else.
Set objMsg = Application.CreateItemFromTemplate("path of template .oft")
'Add sender of original email