Concat 2 SQL columns into 1 UDTable column

Product: PowerShell Universal
Version: 2.8.1

Is something like this possible? I want to output the results of a SQL query but join 2 columns into 1 column in the UDTable.

For example, the SQL result contains 3 columns

  • Id
  • FirstName
  • LastName

And I’d like to create a New-UDTable with 2 columns

  • Id (Id from the SQL result)
  • Name (FirstName + LastName from the SQL result)

Not too sure how to accomplish that, anyone have a hint?

Cheers!
Steve.

I’d just recommend that you do that in your SQL query where you join the two tables together.

Hmm yeah I could alter the SQL query to something like:

SELECT Id,
       FirstName,
       LastName,
       CONCAT(FirstName, ' ', LastName) AS Name
FROM People

Not ideal, but if better than manipulating the System.Data.DataRow that is returned then I can get some changes made to the SQL query.

Thanks for the reply @dkkazak !

I guess another way you could do this is with your column:

New-UDTableColumn -Property FirstName -Title “Name” -Render {
$Name = $($EventData.Firstname) + " " + $($EventData.LastName)
$Name
}

1 Like