title: PIVOT with varchar datatype
body: <p>I´m trying to PIVOT some data in a table, but I cannot do it because I do not find the way to do it using <code>varchar</code> columns. I have this table:</p>
  <p><img src="https://i.stack.imgur.com/xosYs.jpg" alt="enter image description here" /></p>
  <p>And what I need is this:</p>
  <p><img src="https://i.stack.imgur.com/Od5FD.jpg" alt="enter image description here" /></p>
  <p>I need to use the 'ug_label' row data as columns. As the datatype is VARCHAR, I cannot use an agregate function inside the PIVOT.</p>
  <p>I think I might need something like this:</p>
  <pre><code>SELECT *
  FROM
  (SELECT [c_id]
        ,[c_lname] as [Apellido]
        ,[c_fname] as [Nombre]
        ,[c_nick_name] as [documento]      
        ,[ut_text] 
        ,f.ug_label
    FROM [pegasys].[dbo].[cardholder] c
    inner join [pegasys].[dbo].[udftext] u on c.c_id = u.ut_cardholder_id 
    inner join [pegasys].[dbo].[udfgen] f on u.ut_udfgen_id = f.ug_id) AS S  
  PIVOT
  (
      UT_TEXT
      FOR
      [UG_LABEL]
      IN ([Torre], [Cuit], [Empresa], [Departamento])
  ) as s
  </code></pre>
  <p>Can someone help me??.</p>
  <p>Thanks.</p>