|
|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Managed Instance Memory per vCore Limits | |
There are three editions of Azure SQL Managed Instance, as of June 2023 (General Purpose, Business Critical, and Memory-Optimized). What are the amounts of RAM that I get per vCore for these editions? | |
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) |
Getting the Winners I get a JSON string that looks like this: DECLARE @JSON NVARCHAR(MAX) = N'{ "WinnerIDs": [11,14,15,16,45], "Race": "Furry Scurry", "RaceStartDate": "2022-05-20T08:00:00", "RaceEndDate": "2022-05-20T10:00:00", "Entries": 100 }'; I want to parse out the values of the winners to show each on a separate line of the result set. I try a couple of things. First, this: SELECT oj.Race, oj.WinnerIDs FROM OPENJSON (@JSON) WITH (Race NVARCHAR(100) '$.Race' , WinnerIDs NVARCHAR(MAX) '$.WinnerIDs' AS JSON) oj Second, this: SELECT oj.Race, oj2.WinnerIDs FROM OPENJSON (@JSON) WITH (Race NVARCHAR(100) '$.Race' , WinnerIDs NVARCHAR(MAX) '$.WinnerIDs' AS JSON) oj INNER JOIN OPENJSON (@JSON) WITH (Race NVARCHAR(100) '$.Race' , WinnerIDs NVARCHAR(MAX) '$.WinnerIDs' AS JSON) oj2 ON oj.WinnerIDs = oj2.WinnerIDs Third this: SELECT oj.Race, oj.[value] AS WinnerID FROM OPENJSON (JSON_QUERY(@JSON, '$.WinnerIDs')) AS oj Fourth and lastly, this: SELECT oj.Race, oj2.[value] AS WinnerIDs FROM OPENJSON (@JSON) WITH (Race NVARCHAR(100) '$.Race' , WinnerIDs NVARCHAR(MAX) '$.WinnerIDs' AS JSON) oj CROSS APPLY OPENJSON(oj.WinnerIDs) AS oj2 Which of these returns these results? RaceWinnerIDs Furry Scurry11 Furry Scurry14 Furry Scurry15 Furry Scurry16 Furry Scurry45 Answer: Fourth code Explanation: The last query with the cross apply will work. The first and second ones return a single row with all winnerIDs in one column. The third one doesn't work, and the last one does. Note, there are other ways to do this. Ref: |
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 2017 - Administration |
Vulnerability Assessment removed? - In Brent Ozar's list of links today, I learned that Microsoft has removed the Vulnerability Assessment tool from SSMS as of v19.1. I recently started using it in my SQL Server environment and found it a great tool -- I was able to demonstrate to management why some of their security shortcuts were a bad […] |
SQL Server 2017 - Development |
Need help with a Query logic - I have a table which tracks of activity when users from one specific app login and logout. But I have seen some cases where let's say a user logins at 11:40 on March 24th and then logins again at 11:55 on the same day without logging out. The application doesn't allow that but I am […] |
SQL Server 2016 - Administration |
Database copy issue through - COPY DB WIZARD - I have a production server with SQL server 2016 version (13.0.5026.0) and a database with 25 GB of Data and 525 tables in it. Now, I want to transfer this production DB to my development environment with SQL server 2016 version (13.0.5026.0). I am using DB copy wizard for DB copy to the new instance […] |
SQL Server 2016 - Development and T-SQL |
Help with a SQL Unpivot - I am trying to use unpivot to extract some data, however, the results are getting messed up on at least one record. By this I mean it is out of order which it should be CLNUM: MODEL: CLSTATUS: CLSTATDATE: CLSTOP: Here is the query any help or advice would be appreciated. WITH ClientsWithOpenMattersCTE (ClientNo, HowMany) […] |
SQL help with partition - With the following data, I need to create a column that will display a counter for each VID, Acc where PrgFld is not 'XXX' I am trying to do this with partition, but it's increasing the counter when PrgFld is XXX. I would prefer to not increase the counter or show 0 for XXX. Is […] |
NOT LIKE Alternatives in WHERE clause - Hello, I need help to improve an existing (hence I cannot change table's structure nor the content's logic) WHERE clause, please. The table consists of returned products with their respective reason(s). In case there is more than one reason, they are concatenated. The request as shown in the mock-up below, has to retrieve a list […] |
Administration - SQL Server 2014 |
Database backups going to device - Hi Friends, How can I know the exact device where my backups are going on? I only see {67BAB2D0-A1DC-44F8-BF73-EBAFD5AE3220}16 as one device. However, I do not find out where are my backup files located. Some databases are going to a particular drive, but others are using that expression, Thank you, Best Regards, |
SQL Server 2019 - Administration |
Upgrading from 2016 to 2019 with Encryption - Hi, I have a few AWS EC2 instances currently running SQL Server 2016. I'd now like to upgrade these to SQL Server 2019 but the problem is that some of the data has been encrypted at the column level. I understand that, after SQL 2016, the encryption algorithm changed from SHA1 to SHA2. Would this […] |
SQL Server 2019 - Development |
how to de escalte a isolation level, and are there any implications. - hi, I have one nested transaction and want to deescalate to outer transaction's isolation/ or lower isolation. is it the right way? SET TRANSACTION ISOLATION LEVEL read committed; BEGIN TRY BEGIN TRAN DBCC USEROPTIONS --want to do some job in read commited SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; BEGIN TRY BEGIN TRAN DBCC USEROPTIONS --want to […] |
Advanced SQL query help - Hi, I am looking for some help with two queries using the following table/data. It would be great to see the most efficient way to achieve these. Queries 1: Show all homes with rent above the average rent value for their Company 2: Show the number of homes registered 0-3 months, 4-6 months, 6-12 months, […] |
MSSQL Service Broker DSQL operation on another database causing Broker failure - I have established a Service Broker configuration based on Eitan Blumin's excellent example. Advanced Service Broker Sample: Asynchronous Triggers I have crafted my own Stored Procedure. I can get the example to work when I'm performing activities within the same database. If I try to operate outside the current DB I get errors. I'm new […] |
Extracting multiple fields from one column - Hello, I have a situation. I am trying to show each distinct event category, event action and event label from 'Hits' column and show the number of times each event occurred and the month that the event occurred– for labels containing “GNAV”. I am not sure why but something is wrong. Do you have […] |
Analysis Services |
How can I show the last opening period for each project in my project dimension - I have two attributes hierarchies in my dimension [Dim Project]: Project Code Opening date Project A with 3 opening date : 2023-01-01 , 2023-01-02 and 2023-01-03 Project B with 2 opening date : 2023-01-02 , 2023-01-04 MDX query : Select [Dim Project].[Project Code] .[Project Code].Allmembers * [Dim Project].[Opening date].[Opening date].Allmembers on 0 [Measures].[Measure1] on 1 […] |
SQL Server 2022 - Administration |
Allow only encrypted connections. - Hi In SQL22, Is there a way to allow only / force encrypted connections? I have 'force encryption' on and have cert installed: But when I connect via SSMS I can unselect ' Encrypt Connection' and it connects. My understanding is that means that it is allowing non-encrypted connections: How do I make my […] |
SQL Server 2022 - Development |
SQL Query - Hi, i have a sample table: table ID flag name 1 0 test1 1 0 test2 1 1 test3 2 0 test4 2 0 test5 3 1 test6 4 […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |