Showing posts from 2013

Get Immediate and Ultimate Parents with levels

WITH r (id, parent, ultimate_parent, name, ultimate_parent_name, lvl)as(SELECT id, parent_id AS parent, parent_id AS ultimate_parent, name, name as ultimate_parent_name,0 lvl FROM mytable WHERE parent_id = id -- identifies a rootUNIONALLSELECT,, ultimate_parent,, r.ultimate_parent_name, r.lvl +1FROM r join mytable m on m.parent_id = -- joins child with parentWHERE m.parent_id <> -- to avoid cycles)SELECT*FROM r ;The first part of the subquery fetches the roots and the second part connects the children. Parent is the immediate parent andultimate_parent, the ultimate parent.

How to Read TOC Headings from word document using C#

Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application();
object paramMissing = Type.Missing;wordApplication.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
WdExportFormat paramExportFormat = WdExportFormat.wdExportFormatPDF;

bool paramOpenAfterExport = false;WdExportOptimizeFor paramExportOptimizeFor =
WdExportRange paramExportRange = WdExportRange.wdExportAllDocument;

int paramStartPage = 0;
int paramEndPage = 0;WdExportItem paramExportItem = WdExportItem.wdExportDocumentContent;

bool paramIncludeDocProps = true;
bool paramKeepIRM = true;WdExportCreateBookmarks paramCreateBookmarks =

bool paramDocStructureTags = true;
bool paramBitmapMissingFonts = true;
bool paramUseISO19005_1 = false;
// Open the source document.wordDocument = wordApplication.Documents.Open(
ref paramSourceDocPath, ref paramMissing, ref paramMissing,