New answers tagged

1

made it, with something simple ( i'm really bad at programming : Select main.unidade_id, Left(Main.viaturas,Len(Main.viaturas)-1) As "Viaturas" into #temp From ( Select distinct v2.unidade_id, ( Select v1.placa + ',' AS [text()] From frotas.Viaturas_Temp v1 Where v1....


3

As Julien mentioned, dyanamic sql will be your answer for this. Below is an example of using pivoting with an EAV system. It really helps with reading the data. DECLARE @Cols NVARCHAR(MAX) DECLARE @Query NVARCHAR(MAX) DECLARE @ClassName NVARCHAR(50) SET @ClassName = 'customer' SELECT @Cols = STUFF((SELECT distinct ',' + QUOTENAME(property_name) ...



Top 50 recent answers are included