You think that first one was bad? This is the one I'm working on now! Un-Fucking-Real!
code:
SELECT * FROM ProductionHeader WHERE ruhID='041811BD'; SELECT ID=rudID, Category=rudCategory, Seq=rudSeq, Type=rudType, [Product ID]=rudProductID, Description=rudDescrip,
PcsPerPkg=rudPcsPerPkg, Tally=rudTally, UOM=rudBaseUnitID, Pieces=rudPieces, Volume=rudVolume, NetVolume=rudNetVolume, Cost=rudCost, AddedCost= rudAddedCost, MktValue=rudMarketValue,
Total=rudTotal, NetThick=rudNetThick, NetWidth=rudNetWidth, NetLength=rudNetLength, NetType=rudVolType, LocationID=rudLocationID,rudFIFOVolume,rudForceCost,rudBoomID,prdLengthID=(SELECT prdLengthID FROM ProductMaster
WHERE prdID=rudProductID) FROM ProductionDetail WHERE rudID='041811BD' AND rudCategory='Consumed' ORDER BY Seq; SELECT ID=rudID, Category=rudCategory, Seq=rudSeq, Type=rudType, [Product ID]=rudProductID, Description=rudDescrip,
PcsPerPkg=rudPcsPerPkg, Tally=rudTally, UOM=rudBaseUnitID, Pieces=rudPieces, Volume=rudVolume, NetVolume=rudNetVolume, Cost=rudCost, AddedCost= rudAddedCost, MktValue=rudMarketValue, Total=rudTotal, NetThick=rudNetThick,
NetWidth=rudNetWidth, NetLength=rudNetLength, NetType=rudVolType, LocationID=rudLocationID,rudFIFOVolume,rudForceCost,rudBoomID,prdLengthID=(SELECT prdLengthID FROM ProductMaster WHERE prdID=rudProductID)
FROM ProductionDetail WHERE rudID='041811BD' AND rudCategory='Produced' ORDER BY Seq; SELECT uft.uftDocId, uft.uftFieldType, uft.uftValidation, Description = uft.uftCaption, Value = duf.dufValue FROM UserFieldTemplate uft
LEFT JOIN DocumentUserFields duf ON duf.dufDocType = uft.uftDocType AND duf.dufSeq = uft.uftDocId AND duf.dufDocId='041811BD' WHERE uft.uftDocType='PRODUCTION' ORDER BY uft.uftDocId; SELECT ufvDocId, ufvSeq, Value=ufvValue,
Description=ufvDescrip FROM UserFieldValues WHERE ufvDocType='PRODUCTION' ORDER BY ufvDocId, ufvSeq; SELECT dufDocType, dufDocID, dufSeq, dufValue FROM DocumentUserFields WHERE 1=0; SELECT *
,tagParentProdID=ISNULL((SELECT MAX(p2.prdID) FROM ProductMaster p2 WHERE p1.prdThickID=p2.prdThickID AND ((isnull(p2.prdWidthID,'')='' AND isnull(tagHdrWidthID,'')='') or isnull(p2.prdWidthID,'')=tagHdrWidthID)
AND ISNULL(p2.prdLengthID,'') = ISNULL(p1.prdLengthID,'') AND p1.prdSpeciesID=p2.prdSpeciesID AND p1.prdGradeID=p2.prdGradeID AND p1.prdSurfacingID=p2.prdSurfacingID AND p1.prdStateID=p2.prdStateID
AND ISNULL(p1.prdUsrAttribID,'')=ISNULL(p2.prdUsrAttribID,'') AND ISNULL(p1.prdUsrAttribID2,'')=ISNULL(p2.prdUsrAttribID2,'') AND ISNULL(p1.prdUsrAttribID3,'')=ISNULL(p2.prdUsrAttribID3,'')
AND ISNULL(p1.prdUsrAttribID4,'')=ISNULL(p2.prdUsrAttribID4,'') AND ISNULL(p1.prdUsrAttribID5,'')=ISNULL(p2.prdUsrAttribID5,'') AND ISNULL(p1.prdUsrAttribID6,'')=ISNULL(p2.prdUsrAttribID6,'')
AND ISNULL(p1.prdUsrAttribID7,'')=ISNULL(p2.prdUsrAttribID7,'') AND ISNULL(p1.prdUsrAttribID8,'')=ISNULL(p2.prdUsrAttribID8,'') AND ISNULL(p1.prdUsrAttribID9,'')=ISNULL(p2.prdUsrAttribID9,'')
AND p1.prdHidden=1),p1.prdID) FROM TagMaster INNER JOIN ProductMaster p1 ON p1.prdID=tagProductID WHERE tagSourceID='041811BD' AND tagSourceType='PRODUCTION' ORDER BY tagID,tagLineSeq;
SELECT ProductID=rudProductID, LocationID=rudLocationID, Volume=SUM(rudVolume), Type=rudType FROM ProductionDetail WHERE rudID='041811BD' AND rudProductID<>'' AND rudCategory='Produced'
AND rudType='Vol' GROUP BY rudProductID, rudLocationID, rudType; SELECT ProductID=rudProductID, LocationID=rudLocationID, Value=SUM(rudTotal), Type=rudType, rudCategory FROM ProductionDetail
WHERE rudID='041811BD' AND rudProductID<>'' GROUP BY rudProductID, rudLocationID, rudType, rudCategory; SELECT 1 FROM DocumentNotesMaster WHERE dnmDocType='PRODUCTION' AND dnmDocID='041811BD';
SELECT DocType=dcmDocType, DocID=dcmDocID, Seq=dcmSeq, Type=dcmCostTypeID, Description=dcmDescrip, MachineID=dcmMachineID, SuppID=dcmSuppID,FundsID=dcmFundsTypeID, FundsRate=dcmFundsRate, Qty=dcmQty,
CostRate=dcmRateID, Total=dcmTotal, Prorate=dcmProrate, ProductID=dcmProductID, [LineNo]=dcmLineNo FROM DocumentCostMaster WHERE dcmDocType='PRODUCTION' AND dcmDocID='041811BD' ORDER BY dcmSeq