SELECT tLieferschein.cLieferscheinNr AS Lieferscheinnummer
, CONVERT(VARCHAR, tVersand.dVersendet, 104) AS 'Versendet am'
, tVersandart.cAmazonCarrierCode AS 'Logistiker'
, tVersandart.cName AS 'Versandart'
, tVersand.cIdentCode AS 'Tracking ID'
, REPLACE(tVersandart.cTrackingUrlTemplate, '#IdentCode#', tVersand.cIdentCode) AS 'Trackinglink'
, tVersand.cHinweis AS 'Hinweis'
, eazybusiness.dbo.tbenutzer.cName AS Benutzer
FROM tbestellung
JOIN tLieferschein ON tLieferschein.kBestellung = tBestellung.kBestellung
LEFT JOIN tVersand ON tVersand.kLieferschein = tLieferschein.kLieferschein
LEFT JOIN tVersandart ON tVersandart.kVersandart = tVersand.kVersandArt
JOIN eazybusiness.dbo.tbenutzer ON eazybusiness.dbo.tbenutzer.kBenutzer = tVersand.kBenutzer
WHERE tBestellung.kBestellung = @Key