Aqui dejo una posible respuestal, la cual me esta funcionando, solo es una variante de lo de arriba, pero jala bien.
Código:
DECLARE @Names NVARCHAR(MAX)
SET @Names =''
SELECT @Names = @Names + '[' + Nombre + '],'
FROM (SELECT DISTINCT Usuarios.User_Name AS Nombre
FROM Ticket_Approvals INNER JOIN
Usuarios ON Ticket_Approvals.Ticket_Approval_By = Usuarios.User_ID
WHERE Ticket_ID = 3) dd
--PRINT @GroupBy
--print LEN(@Names)
IF (LEN(@Names)>0)
BEGIN
SET @Names = LEFT(@Names, LEN(@Names) -1)
EXEC ('SELECT *
FROM (SELECT Ticket_Detail_ID, Usuarios.User_Name As Nombre,
Ticket_Detail_Status + ' + ''' - ''' + ' + Ticket_Approval_Reason As Status
FROM Ticket_Approvals INNER JOIN Usuarios ON Ticket_Approvals.Ticket_Approval_By = Usuarios.User_ID
WHERE Ticket_ID= 3 GROUP BY Ticket_Approvals.Ticket_Detail_ID,
Usuarios.User_Name,
Ticket_Approvals.Ticket_Detail_Status + ' + ''' - ''' + ' + Ticket_Approvals.Ticket_Approval_Reason) pvt
PIVOT (Max([Status]) FOR [Nombre] IN (' + @Names + ')) AS Child
GROUP BY Ticket_Detail_ID, ' + @Names)
END