Justin Figg

VitaminDBA.com is a source of SQL Server News and Tips coming from a SQL Server sr. database analyst with 10 years of IT experience ranging from Windows Server, Network, and SQL Server administration. I upload articles on the blog on a fairly consistent basis with the intention of at least 1 new article a week.

Blogs

A Fabric solution can be very cost effective

By

Are you currently using Microsoft Fabric or considering migrating to it? If so, there...

Track SQL Server Configuration Changes Using the Error Log

By

Track SQL Server Configuration Changes Using the Error Log If you...

Data Engineering Books Worth Having on Your Shelf (or your tablet)

By

Good documentation gets you started. Good books get you deep. After years of working...

Read the latest Blogs

Forums

SQL Server Showing Out of Space But Plenty of Drive Space

By AMCity

We have a SQL Server installed. We have a 500GB drive for the database....

Creating a JSON Document IV

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Creating a JSON Document IV

Visit the forum

Question of the Day

Creating a JSON Document IV

I have this data in a table called dbo.NFLTeams

TeamID  TeamName       City             YearEstablished
------  --------       ----             ---------------
1       Cowboys        Dallas           1960
2       Eagles         Philadelphia     1933
3       Packers        Green Bay        1919
4       Chiefs         Kansas City      1960
5       49ers          San Francisco    1946
6       Broncos        Denver           1960
7       Seahawks       Seattle          1976
8       Patriots       New England      1960
If I run this code, how many rows are returned?
SELECT 
  YearEstablished,
  json_objectagg(city : TeamName)
FROM dbo.NFLTeams
GROUP BY  YearEstablished;

See possible answers