Vacation Approvals Multiple requests into one request? Not 100% sure if this makes the most sense to try and do in SQL.

What I am trying to achieve, is drive Vacation Approvals through SharePoint Lists using Flow.

Currently I am able to get the data from our scheduling system with the requests as individual rows, however I need to present the request back as a single item.

For Example:



The reason why I need it like this is because when I use Flow to populate the sharepoint list, it seems to be 1:1 mapping from field to field per row.

Not opposed to creating additional tables or request ID system to join all these together.

Thanks in advance,

Craig
For 2017 you can use STRING_AGG. 

DBFIDDLE

create table  #myTable 
([Name] varchar(64), 
 DateOfRequest date, 
 ReqLine int, 
 FromDate date, 
 EndDate date, 
 SchedCode char(2))

insert into #myTable
values
('BSMITH','20190911',1,'20190912','20190912','V8'),
('BSMITH','20190911',2,'20190914','20190915','V8')

select 
  [Name],
  string_agg(DateOfRequest,char(13)) as DateOfRequest,
  string_agg(ReqLine,char(13)) as ReqLine,
  string_agg(FromDate,char(13)) as FromDate,
  string_agg(EndDate,char(13)) as EndDate,
  string_agg(SchedCode,char(13)) as SchedCode
from #myTable
group by [Name]


This won't make your DateOfRequest unique, but if you know it will be the same for each Name then you can just select it, and add it to the group by

select 
    [Name],
    DateOfRequest,
    string_agg(ReqLine,char(13)) as ReqLine,
    string_agg(FromDate,char(13)) as FromDate,
    string_agg(EndDate,char(13)) as EndDate,
    string_agg(SchedCode,char(13)) as SchedCode
  from #myTable
  group by [Name], DateOfRequest