Skip to content

Instantly share code, notes, and snippets.

View mattiaswolff's full-sized avatar

Mattias Wolff mattiaswolff

View GitHub Profile
@mattiaswolff
mattiaswolff / gist:3176681
Created July 25, 2012 15:11
Mediusflow: Unlock reserved tasks
UPDATE e
SET e.reservedby = NULL
FROM ERRAND e
INNER JOIN ERRAND_HISTORY eh ON (e.ID = eh.ERRANDID
AND eh.Tag = 'ERRAND_RESERVED')
WHERE e.RESERVEDBY IS NOT NULL
AND eh.MODIFIEDDATE < DATEADD(MINUTE, -60, GETDATE())
AND eh.ID =
(SELECT top 1 ID
FROM ERRAND_HISTORY
@mattiaswolff
mattiaswolff / gist:3180991
Created July 26, 2012 08:32
Mediusflow: Re-send integration postings (Final postings / paymenttransferred = 10)
-- Update rowstate to posted
UPDATE NAV_IN_MESSAGE_TAB_TRANS
SET ROWSTATE = 'Posted'
WHERE message_id IN
(SELECT message_id
FROM nav_in_message_tab_trans nimtt
INNER JOIN ERRAND e ON (e.ID = nimtt.ERRAND_ID)
INNER JOIN INVOICE_HEAD ih ON (e.INVOICEID = ih.ID)
WHERE ih.PaymentTransferred = 10
AND e.VISIBLE = 0
@mattiaswolff
mattiaswolff / gist:3180994
Created July 26, 2012 08:33
Mediusflow: Re-send integration postings (Final postings / paymenttransferred = 6)
UPDATE NAV_IN_MESSAGE_TAB_TRANS
SET ROWSTATE = 'Posted'
WHERE message_id IN
(SELECT message_id
FROM nav_in_message_tab_trans nimtt
INNER JOIN ERRAND e ON (e.ID = nimtt.ERRAND_ID)
INNER JOIN INVOICE_HEAD ih ON (e.INVOICEID = ih.ID)
WHERE ih.PaymentTransferred = 6
AND e.VISIBLE = 0
AND nimtt.MESSAGE_ID IN
@mattiaswolff
mattiaswolff / gist:3181050
Created July 26, 2012 08:47
Mediusflow: Empty Iflow_log (Multiple databases supported)
SET nocount ON DECLARE @intC integer DECLARE @intD integer DECLARE @intMax integer DECLARE @intMin integer DECLARE @strString nvarchar(1000) DECLARE @Databases TABLE (ID int, Name nvarchar(200))
INSERT INTO @Databases (ID, Name)
SELECT database_id,
name
FROM sys.databases
WHERE name LIKE '[[DATABASE_NAME]]' -- REPLACE WITH DATABASE NAME ('%' can be used to use several databases)
SET @intC = 0 While @intC <
(SELECT MAX(ID)
FROM @Databases) BEGIN
SET @intC =
@mattiaswolff
mattiaswolff / gist:3187518
Created July 27, 2012 11:39
WinSCP: Download files script file
option batch abort
option confirm off
open [[USERNAME]]:[[PASSWORD]]@[[SERVER]]:[[PORT]]
get ./*.* "[[OUTPUT PATH]]"
rm ./*.*
exit
@mattiaswolff
mattiaswolff / gist:3187558
Created July 27, 2012 11:47
7-Zip: Extract files
"[[PATH TO 7-ZIP]]\7z.exe" e "[[PATH TO ZIP-FILES]]" -o"[[PATH TO OUTPUT FILES]]" [[FILES TO UNZIP]]
"c:\Program Files\7-Zip\7z.exe" e "C:\MIG_Services\ReadsoftOnline Demo\STH1\Import\" -o"C:\MIG_Services\ReadsoftOnline Demo\STH1\Unzipped\" *.xml
@mattiaswolff
mattiaswolff / gist:3187768
Created July 27, 2012 12:53
Mediusflow: Create partner for invoice import
--Please notice this script does not check if inserted values already exist. This needs to be done manually.
--Replace: [[ARCHIVE PATH]]
--Replace: [[ROLE]]
--Replace: [[PARTNER NAME]]
--Replace: [[PARTNER DESCRIPTION]]
UPDATE permission
SET ACTIVE = -1
WHERE TAG = 'DOWNLOAD_INVOICE_EDI_SOURCE'
UPDATE permission
@mattiaswolff
mattiaswolff / gist:3357920
Created August 15, 2012 09:11
CMD: Rename files from *.prc to *.sql
REN *.prc *.sql
@mattiaswolff
mattiaswolff / gist:3434801
Created August 23, 2012 09:44
Mediusflow: Get invoice information on all invoices on one project
declare @strAccount nvarchar(20)
declare @strCompanyId nvarchar(20)
set @strAccount = ''
set @strCompanyId = ''
SELECT InvoiceNumber,
VerificationIdentity,
SupplierName,
ps.SupplierId,
@mattiaswolff
mattiaswolff / gist:3496506
Created August 28, 2012 09:24
SQL: Free text search in stored procedures ect.
SELECT OBJECT_NAME(id)
FROM syscomments
WHERE [text] LIKE '[[Text to search for]]'
GROUP BY OBJECT_NAME(id)
ORDER BY OBJECT_NAME(id)