[COLOR=blue][FONT=Consolas]CREATE PROCEDURE[/FONT][/COLOR][COLOR=teal][FONT=Consolas][dbo][/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas][spCheckInTimePersonal][/FONT][/COLOR]
[COLOR=green][FONT=Consolas]-- Add the parameters for the stored procedure here[/FONT][/COLOR]
[COLOR=teal][FONT=Consolas]@Evid[/FONT][/COLOR][COLOR=blue][FONT=Consolas]int[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]AS[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]BEGIN[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]SETNOCOUNTON[/FONT][/COLOR][COLOR=gray][FONT=Consolas];[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]SELECTDISTINCT[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblPersonal[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]SMSNummer[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Nachname[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Vorname[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Nachname[/FONT][/COLOR][COLOR=gray][FONT=Consolas]+[/FONT][/COLOR][COLOR=red][FONT=Consolas]' '[/FONT][/COLOR][COLOR=gray][FONT=Consolas]+[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Vorname[/FONT][/COLOR][COLOR=blue][FONT=Consolas]AS[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Mitarbeiter[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Barcode[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR]
[COLOR=fuchsia][FONT=Consolas]Min[/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Einsatzzeitvon[/FONT][/COLOR][COLOR=gray][FONT=Consolas])[/FONT][/COLOR][COLOR=blue][FONT=Consolas]AS[/FONT][/COLOR][COLOR=teal][FONT=Consolas]CheckinZeit[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=fuchsia][FONT=Consolas]Max[/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Einsatzzeitbis[/FONT][/COLOR][COLOR=gray][FONT=Consolas])[/FONT][/COLOR][COLOR=blue][FONT=Consolas]AS[/FONT][/COLOR][COLOR=teal][FONT=Consolas]CheckoutZeit[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR]
[COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]MaID[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR]
[COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=blue][FONT=Consolas]select[/FONT][/COLOR][COLOR=teal][FONT=Consolas]dbo[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]sfFindKurzcode[/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas]@Evid[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Barcode[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=fuchsia][FONT=Consolas]Min[/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Einsatzzeitvon[/FONT][/COLOR][COLOR=gray][FONT=Consolas])))[/FONT][/COLOR][COLOR=blue][FONT=Consolas]as[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Kurzcode[/FONT][/COLOR][COLOR=gray][FONT=Consolas], --here is UDF1[/FONT][/COLOR]
[COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=blue][FONT=Consolas]select[/FONT][/COLOR][COLOR=teal][FONT=Consolas]dbo[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]sfFindEvLocBerID[/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas]@Evid[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Barcode[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=fuchsia][FONT=Consolas]Min[/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Einsatzzeitvon[/FONT][/COLOR][COLOR=gray][FONT=Consolas])))[/FONT][/COLOR][COLOR=blue][FONT=Consolas]AS[/FONT][/COLOR][COLOR=teal][FONT=Consolas]EvLocBerID[/FONT][/COLOR][COLOR=gray][FONT=Consolas], -- here is UDF2[/FONT][/COLOR]
[COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]GeschlechtText[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR]
[COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Geschlecht[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR]
[COLOR=teal][FONT=Consolas]tblPersonal[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]RegID[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]FROM [/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas]INNERJOIN[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblPersonal[/FONT][/COLOR][COLOR=blue][FONT=Consolas]ON[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]MaID[/FONT][/COLOR][COLOR=gray][FONT=Consolas]=[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblPersonal[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]MaID[/FONT][/COLOR][COLOR=gray][FONT=Consolas])INNERJOIN[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventAnmeldungen[/FONT][/COLOR][COLOR=blue][FONT=Consolas]ON[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblPersonal[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]MaID[/FONT][/COLOR][COLOR=gray][FONT=Consolas]=[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventAnmeldungen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]MaID[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]WHERE [/FONT][/COLOR][COLOR=gray][FONT=Consolas]((([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventAnmeldungen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=blue][FONT=Consolas]Status[/FONT][/COLOR][COLOR=gray][FONT=Consolas])=[/FONT][/COLOR][COLOR=red][FONT=Consolas]'OK'[/FONT][/COLOR][COLOR=gray][FONT=Consolas])AND(([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventAnmeldungen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]EvID[/FONT][/COLOR][COLOR=gray][FONT=Consolas])=[/FONT][/COLOR][COLOR=teal][FONT=Consolas]@Evid[/FONT][/COLOR][COLOR=gray][FONT=Consolas])AND(([/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]EvID[/FONT][/COLOR][COLOR=gray][FONT=Consolas])=[/FONT][/COLOR][COLOR=teal][FONT=Consolas]@Evid[/FONT][/COLOR][COLOR=gray][FONT=Consolas]))[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]GROUPBY[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblPersonal[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]SMSNummer[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Nachname[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Vorname[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Barcode[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]MaID[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]GeschlechtText[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblEventPositionen[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]Geschlecht[/FONT][/COLOR][COLOR=gray][FONT=Consolas],[/FONT][/COLOR][COLOR=teal][FONT=Consolas]tblPersonal[/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas]RegID[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]HAVING [/FONT][/COLOR][COLOR=gray][FONT=Consolas]((([/FONT][/COLOR][COLOR=fuchsia][FONT=Consolas]Len[/FONT][/COLOR][COLOR=gray][FONT=Consolas]([/FONT][/COLOR][COLOR=teal][FONT=Consolas][tblPersonal][/FONT][/COLOR][COLOR=gray][FONT=Consolas].[/FONT][/COLOR][COLOR=teal][FONT=Consolas][SMSNummer][/FONT][/COLOR][COLOR=gray][FONT=Consolas]))>[/FONT][/COLOR][COLOR=black][FONT=Consolas]0[/FONT][/COLOR][COLOR=gray][FONT=Consolas]));[/FONT][/COLOR]
[COLOR=blue][FONT=Consolas]END[/FONT][/COLOR]