B
B
Bogdan2020-02-19 13:12:32
SQL Server
Bogdan, 2020-02-19 13:12:32

How to display array inside Ms Sql table for PowerBI?

There are two tables in the Ms Sql database, one stores Id as an array in square brackets, separated by commas. The second one stores the values ​​of these Ids in Russian for a specific field.
How to display information in a human-readable form, with the ability to work with it in PowerBI? Or at least in SSMS.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-02-19
@Crytothemoon

DECLARE @ITEM VARCHAR(100) = '[ 3102, 3106]'
SELECT CAST( value AS INT ) AS ITEM 
  FROM STRING_SPLIT( SUBSTRING( @ITEM, 2, DATALENGTH( @ITEM ) - 2 ), ',')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question