sql-server-2017

SQL to JSON - Grouping Results into JSON Array

吃可爱长大的小学妹 提交于 2020-02-28 07:21:47
问题 I am trying to come up with an SQL solution for arranging output to match an expected JSON format. I have some simple SQL to highlight where the issue is coming from; SELECT TOP 1 'Surname' AS 'name.family' ,'Forename, Middle Name' AS 'name.given' ,'Title' AS 'name.prefix' ,getDATE() AS 'birthdate' ,'F' AS 'gender' ,'Yes' AS 'active' ,'work' AS 'telecom.use' ,'phone' AS 'telecom.system' ,'12344556' AS 'telecom.value' FROM tblCustomer FOR json path Which will return JSON as; [ { "name": {

SQL to JSON - Grouping Results into JSON Array

倾然丶 夕夏残阳落幕 提交于 2020-02-28 07:20:08
问题 I am trying to come up with an SQL solution for arranging output to match an expected JSON format. I have some simple SQL to highlight where the issue is coming from; SELECT TOP 1 'Surname' AS 'name.family' ,'Forename, Middle Name' AS 'name.given' ,'Title' AS 'name.prefix' ,getDATE() AS 'birthdate' ,'F' AS 'gender' ,'Yes' AS 'active' ,'work' AS 'telecom.use' ,'phone' AS 'telecom.system' ,'12344556' AS 'telecom.value' FROM tblCustomer FOR json path Which will return JSON as; [ { "name": {

sql combine rows with same date

徘徊边缘 提交于 2020-01-16 19:00:27
问题 I want to combine rows when they have same date and Item# while aggregating received QTY and Outstanding QTY. Also, PO# should be combined with “, “. Please refer to the image or table below. Thank you in advance!! This is my SQL Query... SELECT * from [mason01].[dbo].[po_east] as t1 inner join (select distinct [Date],[ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding] FROM [mason01].[dbo].[po_east] group by [Date], [ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding]) as t2 on t1.Date

sql combine rows with same date

倾然丶 夕夏残阳落幕 提交于 2020-01-16 19:00:11
问题 I want to combine rows when they have same date and Item# while aggregating received QTY and Outstanding QTY. Also, PO# should be combined with “, “. Please refer to the image or table below. Thank you in advance!! This is my SQL Query... SELECT * from [mason01].[dbo].[po_east] as t1 inner join (select distinct [Date],[ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding] FROM [mason01].[dbo].[po_east] group by [Date], [ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding]) as t2 on t1.Date

enumerating rows in sql with multiple same values

微笑、不失礼 提交于 2020-01-15 09:23:38
问题 I want to enumerate rows such that non-unique values get the same number and do not increase. So my data should look like: id - term_seq_id - rn --------------------- 1 0944 1 1 0944 1 1 0962 2 2 1024 1 2 1054 2 I was looking at this solution: SQL: enumerate returned rows within each group Which works if the values are all unique in the ORDER BY statement in the window function. So I have the following query from this solution but it doesn't work: SELECT student_id_fk , Term_Seq_Id , ROW

SQL Server 2017 Developer edition installation is stuck (hung up) endlessly

女生的网名这么多〃 提交于 2020-01-14 12:38:53
问题 After overcoming this and this issue my hurdles don't seem to be coming to an end. SQL Server 2017 Developer edition installation is going on endlessly. The installer isn't coming to an end and seems to have stuck on below step for last few days now: Install_MsMpi_Cpu64_Action My task manager shows as below for this ongoing installation: Here is what I saw through process explorer tool if that provides any clue: Operating System Info : Windows 10 This machine is freshly built and there are no

SQL get all Payments where sum > 10,000 in 72 hours

廉价感情. 提交于 2019-12-25 18:55:41
问题 i'm working on a fictional payment database, and i want to check if there are payments from a merchant which sum of it goes above 10k within 72 hours from each other. SELECT o.MerchantID, SUM(Amount) FROM Payments p INNER JOIN Orders o ON p.OrderID = o.ID WHERE MerchantCreatedOrderOn BETWEEN MerchantCreatedOrderOn AND DATEADD(HOUR, 72, MerchantCreatedOrderOn) GROUP BY o.MerchantID, o.MerchantCreatedOrderOn, p.ID HAVING SUM(o.Amount) >= 10000; now my where clause isn't right yet, i now get

Create a new table and adding a data from old one in SQL Server 2017 in one query

北城余情 提交于 2019-12-25 18:22:07
问题 I have a main table that contains all cities and regions in Switzerland. I want to create a table for each city, and copy the city data directly from the main to the new one according to its abbreviation. For example, create a table for Zurich and copy all data from the old table when the abbreviation is ZH. create a table for Schaffhausen and copy all data from the old table when the abbreviation is SH. I've used the following query, but did not work: CREATE TABLE Zurich AS SELECT * FROM

How to do Where clause on simple Json Array in SQL Server 2017?

柔情痞子 提交于 2019-12-25 03:20:29
问题 Say I have a column in my database called attributes which has this value as an example: {"pages":["Page1"]} How can I do a where clause so I can filter down rows that have "Page1" in it. select JSON_QUERY(Attributes, '$.pages') from Table where JSON_QUERY(Attributes, '$.pages') in ('Page1') Edit: From the docs it seems like this might work though it seems so complicated for what it is doing. select count(*) from T c cross apply Openjson(c.Attributes) with (pages nvarchar(max) '$.pages' as

Report Manager Expression-based Connection Strings Missing

自古美人都是妖i 提交于 2019-12-24 18:25:58
问题 I'm using an expression for a report connection string but when I upload the report to the report manager (2017 June) and save the credentials in the data source setting the text box that contains the expression gets cleared out. The same report works fine in SSRS 2014. I've tried using IE, Chrome and Edge and get the same behaviour. before save after save 回答1: I had a similar issue in ReportServer 2017; however, if you click the button 'Revert to Default' (a button displayed in the same