Note that there are some explanatory texts on larger screens.

plurals
  1. POMicrosoft SQL Server Stored Procedure with a single field
    text
    copied!<p>After three days of intensive Googling, trying, failing, bargaining and getting angry. I have accepted my fate and decided to ask you. I will try to be as clear as possible here. .</p> <p>I am trying to select a single field from the database (via a SP) here are some of the things I have tried:</p> <p><strong>Subquerywise:</strong> </p> <pre><code>( SELECT dbo.T_MemoDetail.Info FROM dbo.T_MemoDetail INNER JOIN dbo.T_DossierDetail AS T_DossierDetail ON T_DossierDetail.MemoGrpId = dbo.T_MemoDetail.MemoGrpId INNER JOIN dbo.T_DossierMain AS T_DossierMain ON T_DossierDetail.DossierCode = T_DossierMain.DossierCode WHERE T_DossierDetail.MemoGrpId = dbo.T_MemoDetail.MemoGrpId AND T_DossierDetail.DossierCode = T_DossierMain.DossierCode AND T_DossierMain.OrdNr = 'BVR13-0710' ), </code></pre> <p>^Returns 2 Strings</p> <pre><code>SELECT /*Selects a lot more, but i do not want to paste the whole SP here*/ T_MemoDetail.Info **Note that this isn't a subquery** /*Selecting more data beneath here*/ FROM dbo.T_DossierMain INNER JOIN dbo.T_DossierDetail AS t10 ON t10.DossierCode = t1.DossierCode INNER JOIN dbo.T_MemoDetail AS T_MemoDetail ON T_MemoDetail.MemoGrpId = t10.MemoGrpId AND t10.DossierCode = t1.DossierCode </code></pre> <p>also tried using a Temporary table with both ways<br> <code>CREATE TABLE #Temp ....... INSERT INTO SELECT</code><br> and<br> <code>SELECT ...... INTO #Temp</code></p> <p><strong>ONLY</strong> links between the damn tables</p> <pre><code>T_DossierDetail.MemoGrpId = dbo.T_MemoDetail.MemoGrpId AND T_DossierDetail.DossierCode = T_DossierMain.DossierCode AND T_DossierMain.OrdNr BETWEEN @OrdFrom AND @OrdTo (filled with textboxes in FastReport) </code></pre> <p><strong>NOTE</strong> The only value in the table <code>T_DossierDetail</code> that is Distinct is the combination of DetailCode and DetailSubCode</p> <p>If anyone can help me out with this one, I would be so greatfull</p> <p><strong>EDIT 1.1</strong> </p> <p>Hope this helps...</p> <p>(Usable) values for T_DossierDetail: </p> <pre><code>MemoGrpId,DossierCode,DetailCode,DetailSubCode 5468, 015402,010,000 5469, 015402,020,000 </code></pre> <p>(Usable) values for T_DossierMain:</p> <pre><code>OrdNr,T_DossierMain.DossierCode BVR13-0710, 015402 </code></pre> <p>(Usable) values for T_DossierMain:</p> <pre><code>T_MemoDetail.MemoGrpId, T_MemoDetail.Info 5468, [CompanyName] Logo 5469, [CompanyName] Logo </code></pre> <p>All values are returned as strings, not int, double, float or anything STRINGS ONLY (for some reason), FYI: I'm just an intern</p> <p><img src="https://i.stack.imgur.com/N0F8O.png" alt="The &quot;Involves&quot; tables"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload