question

CarlosBarini-9636 avatar image
0 Votes"
CarlosBarini-9636 asked YitzhakKhabinsky-0887 commented

T-SQL JSON Join using varchar field

109023-image.png



I need to return three lines:
1- meat / carne
2- meat / boi
3- meat / boi gordo

How can I do that?

sql-server-transact-sql
image.png (6.7 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@CarlosBarini-9636,

While asking a question you need to provide a minimal reproducible example:
(1) DDL and sample data population, i.e. CREATE table(s) plus INSERT, T-SQL statements.
(2) What you need to do, i.e. logic, and your attempt implementation of it in T-SQL.
(3) Desired output based on the sample data in the #1 above.
(4) Your SQL Server version (SELECT @@version;)

0 Votes 0 ·

I understand it was enought clear because @Viorel-1 gave us the accepted answer without any doubt. If @Viorel-1 could understand others can.

Tahnk you.

0 Votes 0 ·

@CarlosBarini-9636,

You made this post useless for others.
Without a minimal reproducible example, nobody can take Viorel's answer, run it, test it, understand it, and apply it in their environment.

1 Vote 1 ·

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

Try this query:

 select word, [synonym]
 from adlWordBags
 cross apply OPENJSON(JSONSynonyms) with ( [synonym] nvarchar(max) '$.word' )
 where JSONSynonyms <> ''
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.