|
|
|
|
|
|
| Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Fun with JSON I | |
I have some data in a table:
CREATE TABLE #test_data
(
id INT PRIMARY KEY,
name VARCHAR(100),
birth_date DATE
);
-- Step 2: Insert rows
INSERT INTO #test_data
VALUES
(1, 'Olivia', '2025-01-05'),
(2, 'Emma', '2025-03-02'),
(3, 'Liam', '2025-11-15'),
(4, 'Noah', '2025-12-22');
If I run this query, how many rows are returned?
SELECT *
FROM OPENJSON(
(
SELECT t.* FROM #test_data AS t FOR JSON PATH
)
) t; | |
Think you know the answer? Click here, and find out if you are right. | |
| Yesterday's Question of the Day (by Steve Jones - SSC Editor) |
A Quick Restore While doing some testing of an application, I wanted to reset my environment after doing some testing with this code: USE DNRTest BACKUP DATABASE DNRTest TO DISK = 'dnrtest.bak' GO /* Bunch of stuff tested here */RESTORE DATABASE DNRTest FROM DISK = 'dnrtest.bak' WITH REPLACE What happens if this runs, assuming the "bunch of stuff" isn't anything affecting the instance. Answer: This returns an error, and the database isn't restored Explanation: This returns an error: Msg 3102, Level 16, State 1, Line 5 RESTORE cannot process database 'DNRTest' because it is in use by this session. It is recommended that the master database be used when performing this operation. Msg 3013, Level 16, State 1, Line 5 RESTORE DATABASE is terminating abnormally. Ref: RESTORE - https://learn.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-ver17 |
| Database Pros Who Need Your Help |
Here's a few of the new posts today on the forums. To see more, visit the forums. |
| SQL Server 2019 - Development |
| Which 'Where' statement conditional upon a variable - Thanks in advance for any clues on this. I am trying to write a 'conditional where' statement in a typical select statement. Early in the stored procedure the variable @Type is set to either 'AB or 'CD'. I'm trying to have my WHERE be dependent on that variable e.g.: WHEN @Type = 'AB' my "WHERE" […] |
| Integration Services |
| Foreach Loop still executes after process and delete all the folders - I have two challenges XML source control not displaying the XML file parent node columns even though it is showing in the XSD file. Is there any solution to get the XML parent nodes columns in the XML source component. Foreach loop container control not stopping. it still executes if more than two files in […] |
| Editorials |
| Can You Let Go of Determinism - Comments posted to this topic are about the item Can You Let Go of Determinism |
| Doing Good at SQL Server Central - Comments posted to this topic are about the item Doing Good at SQL Server Central |
| Engineer Lessons - Comments posted to this topic are about the item Engineer Lessons |
| Article Discussions by Author |
| Lots of FKs - Comments posted to this topic are about the item Lots of FKs |
| Real-time On-prem SQL Server Data in Excel – Over the Internet - Comments posted to this topic are about the item Real-time On-prem SQL Server Data in Excel – Over the Internet |
| The day-to-day pressures of a DBA team, and how we can work smarter with automation and AI - Comments posted to this topic are about the item The day-to-day pressures of a DBA team, and how we can work smarter with automation and AI |
| Missing the Jaro Winkler Distance - Comments posted to this topic are about the item Missing the Jaro Winkler Distance |
| 25 Years Later: What SQLServerCentral Meant to Me - Comments posted to this topic are about the item 25 Years Later: What SQLServerCentral Meant to Me |
| Fun with JSON - Comments posted to this topic are about the item Fun with JSON |
| Creating JSON II - Comments posted to this topic are about the item Creating JSON II |
| SQL Server 2022 - Development |
| AllocationType as ROW_OVERFLOW_DATA - Hello, I inherited a number of tables with like 20-30 column using nvarchar(256) in each of the tables, when, in fact, the values stored in those tables are way less than 256. So the Actual Size of each row in those tables is way less then 500, but when I run below queries for my […] |
| connections vs apis - hi , i hear more and more that we have too many connections to our servers. many are sql. many arent. so we are told to use api's where possible. Isnt there a connection behind the scenes when an api is asked to return data from whatever the erp's database is> |
| is it true we cant debug c# scripts in ssis anymore under vs - Hi, i'm running vs2022. I'm trying out a c# script that i'd like to set breakpoints on to trap the exception that gets thrown when i debug. From what i'm reading, i cant debug it because my runtime bitness is 64 and that setting cant be changed (it is greyed for me) in vs2022. is […] |
| |
| ©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |