Skip to main content

Posts

Showing posts from November, 2018

SQL Server - How to get first and last day of month

----Today SELECT GETDATE () 'Today' ----Yesterday SELECT DATEADD ( d ,- 1 , GETDATE ()) 'Yesterday' ----First Day of Current Week SELECT DATEADD ( wk , DATEDIFF ( wk , 0 , GETDATE ()), 0 ) 'First Day of Current Week' ----Last Day of Current Week SELECT DATEADD ( wk , DATEDIFF ( wk , 0 , GETDATE ()), 6 ) 'Last Day of Current Week' ----First Day of Last Week SELECT DATEADD ( wk , DATEDIFF ( wk , 7 , GETDATE ()), 0 ) 'First Day of Last Week' ----Last Day of Last Week SELECT DATEADD ( wk , DATEDIFF ( wk , 7 , GETDATE ()), 6 ) 'Last Day of Last Week' ----First Day of Current Month SELECT DATEADD ( mm , DATEDIFF ( mm , 0 , GETDATE ()), 0 ) 'First Day of Current Month' ----Last Day of Current Month SELECT DATEADD ( ms ,- 3 , DATEADD ( mm , 0 , DATEADD ( mm , DATEDIFF ( mm , 0 , GETDATE ())+ 1 , 0 ))) 'Last Day of Current Month' ----First Day of Last Month SELECT DATEADD ( mm ,- 1 , DATEADD ( mm , DATEDIFF ( mm ,

SQL Server - Call a webservice/WebAPI from TSQL code?

Stored Procedure to call Web Service sp_configure 'Ole Automation Procedures', 1 GO RECONFIGURE; GO sp_configure 'show advanced options', 1 GO RECONFIGURE; CREATE PROCEDURE CALLWEBSERVICE AS BEGIN     Declare @Object as Int;     Declare @ResponseText as Varchar(8000);     Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;     Exec sp_OAMethod @Object, 'open', NULL, 'get', 'https://jsonplaceholder.typicode.com/todos/1','false'     Exec sp_OAMethod @Object, 'send'     Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT     Select @ResponseText     Exec sp_OADestroy @Object END Ref: https://stackoverflow.com/questions/33449/can-you-call-a-webservice-from-tsql-code

Merge memorystreams to one iText document

Working code for me :)   Ref - https://stackoverflow.com/questions/8385690/merge-memorystreams-to-one-itext-document The error PDF header signature not found can be fixed in this case by setting the stream's Position back to 0 . Since you're not getting the error Cannot access a closed Stream I'm assuming that you are already correctly setting the PdfWriter 's CloseStream to false . Below is a full working C# 2010 WinForm app targeting iTextSharp 5.1.1.0 that creates three PDFs in MemoryStreams and combines them. Since I don't have a web server handy I'm writing them to disk. using System ; using System . Text ; using System . Windows . Forms ; using System . IO ; using iTextSharp . text ; using iTextSharp . text . pdf ; namespace WindowsFormsApplication1 { public partial class Form1 : Form