Skip to content

Instantly share code, notes, and snippets.


Kirill Pashkov KirillPashkov

View GitHub Profile
View Sybase ASE 15. SQL full outer join without full outer join
select t1.c1, t2.c1 from t1 left join t2 on t1.c1=t2.c1
union all
select t1.c1, t2.c1 from t1 right join t2 on t1.c1=t2.c1
where t1.c1 is null
order by 1, 2;
View VBS find in array
Function FindInArray(InputArray,LookupValue)
Dim Found: Found = False
For i = 0 To UBound(InputArray)
If InputArray(i) = LookupValue Then
Found = True
Exit For
End If
FindInArray = Found
End Function
View VBS match regex to string
Function MatchRegex(RegexPattern,InputString)
If _
IsNull(RegexPattern) Or IsEmpty(RegexPattern) Or _
IsNull(InputString) Or IsEmpty(InputString) _
MatchRegex = False
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = RegexPattern
View T-SQL User&Server OPTIONS
DBCC USEROPTIONS; --for user options
@@OPTIONS; --for server options
DECLARE @options INT
SELECT @options = @@OPTIONS
PRINT @options
IF ( (1 & @options) = 1 ) PRINT 'DISABLE_DEF_CNST_CHK'
View T-SQL Transaction inside Cursor
-- Microsoft SQL Server 2014 (SP2) (KB3171021) - 12.0.5000.0 (X64) Jun 17 2016 19:14:09 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
set nocount on
set cursor_close_on_commit off
if object_id('tempdb..#t', 'U') is not null
drop table #t
create table #t (num int)
insert #t values (1),(2),(3),(4);
View Run Powershell command via VBS
Function InvokePS(Command)
cmd = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command " & Command
Set shell = CreateObject("WScript.Shell")
Set executor = shell.Exec(cmd)
InvokePS = executor.StdOut.ReadAll
End Function
Output = REPLACE(InvokePS(Command),vbCrLf,"")
View VBS IfNull function
Function IfNull(Expression,Replacement)
if IsNull(Expression) then
IfNull = Replacement
IfNull = Expression
End If
End Function
View VBS create csv from sql result set via Systematica Modullar
Function CreateCSV(InputMessageName,OutputMessageName,Delimiter)
Set sb = Application.CreateStringBuilder
If IsNull(Delimiter) OR IsEmpty(Delimiter) Then
Delimiter = ";"
End If
If IsNull(OutputMessageName) OR IsEmpty(OutputMessageName) Then
OutputMessageName = "CSV"
End If
View VBS get number of occurrences
Find = chr(34)
Str = "This is string with " & chr(34) & "double quotes" & chr(34) & "."
Occurrences = (Len(Str) - Len(Replace(Str,Find,Empty)) / Len(Find))
MsgBox "String: " & Str & vbCrLf &_
"Contains :" & Occurrences & " occurrences of: " & Find & "."
Function GetOccurrences(InputString,LookupString)
If _
IsNull(InputString) Or IsEmpty(InputString) Or _
IsNull(LookupString) Or IsEmpty(LookupString) _
View Open Directory Select File.ps1
$ps = New-Object System.Diagnostics.ProcessStartInfo
$ps.FileName = 'explorer'
$ps.Arguments = '/select, ' + $Path