Business Intelligence
35 Topicsduplicate nodes for XML Auto
Hi, I have this xml in SQL Server 2022. select cust.cust_Id, id, timestamp, uid, [user], visible, [version], changeset, [action] , (SELECT distinct ref FROM [nd] as nd where nd.cust_Id = cust.cust_Id and tag.cust_Id = ND.cust_Id FOR XML raw('nd'), type ), k , v from cust as cust join [dbo].[nd] as nd on ND.cust_Id = cust.cust_Id join cust_tags as tag on tag.cust_Id = cust.cust_Id where cust.cust_Id=23165 for xml auto and it gives me this result. As you can see it get duplicates. Apart from the dups in <tag> it''s fine. <cust cust_Id="23165" id="1132454103" timestamp="2023-01-16T14:25:54" uid="5612131" user="k" visible="1" version="1" changeset="131338301"> <nd ref="10239832277" /> <nd ref="10559433751" /> <nd ref="10559433752" /> <nd ref="10559433753" /> <tag k="highcust" v="residential" /> <tag k="highcust" v="residential" /> <tag k="highcust" v="residential" /> <tag k="highcust" v="residential" /> <tag k="name" v="Artemis" /> <tag k="name" v="Artemis" /> <tag k="name" v="Artemis" /> <tag k="name" v="Artemis" /> <tag k="source" v="maxar" /> <tag k="source" v="maxar" /> <tag k="source" v="maxar" /> <tag k="source" v="maxar" /> </cust> Now I have modified it like this: select cust.cust_Id, id, timestamp, uid, [user], visible, [version], changeset, [action], (SELECT ref FROM [nd] as nd where nd.cust_Id = cust.cust_Id FOR XML raw('nd'), type ) , (SELECT k , v FROM cust_tags as tag where tag.cust_Id = cust.cust_Id FOR XML raw('tag'), TYPE ) from cust as cust join cust_tags as tag on tag.cust_Id = cust.cust_Id join [GIS].[dbo].[nd] as nd on ND.cust_Id = cust.cust_Id for xml auto This gives me the structure I want but the node appears multiple times as a duplicate , 5+ times due to the joins <cust cust_Id="23165" id="1132454103" timestamp="2023-01-16T14:25:54" uid="5612131" user="k" visible="1" version="1" changeset="131338301"> <nd ref="10239832277" /> <nd ref="10559433751" /> <nd ref="10559433752" /> <nd ref="10559433753" /> <tag k="highcust" v="residential" /> <tag k="name" v="Artemis" /> <tag k="source" v="maxar" /> </cust> <cust cust_Id="23165" id="1132454103" timestamp="2023-01-16T14:25:54" uid="5612131" user="k" visible="1" version="1" changeset="131338301"> <nd ref="10239832277" /> <nd ref="10559433751" /> <nd ref="10559433752" /> <nd ref="10559433753" /> <tag k="highcust" v="residential" /> <tag k="name" v="Artemis" /> <tag k="source" v="maxar" /> </cust> <cust cust_Id="23165" id="1132454103" timestamp="2023-01-16T14:25:54" uid="5612131" user="k" visible="1" version="1" changeset="131338301"> <nd ref="10239832277" /> <nd ref="10559433751" /> <nd ref="10559433752" /> <nd ref="10559433753" /> <tag k="highcust" v="residential" /> <tag k="name" v="Artemis" /> <tag k="source" v="maxar" /> </cust> Any idea how i can get rid of the duplicates. Either in the fist sql or the second. Thank you!Solved34Views0likes2CommentsERROR 4819
SQL Server: 2019 ERROR (4819) -" Cannot bulk load. The bulk data stream was incorrectly specified as sorted or the data violates a uniqueness constraint imposed by the target table. Sort order incorrect for the follow" We tested the exact same stored procedures on SQL2019 System A and everything worked as expected. But it gives errors when we test on the SQL SERVER 2019 System B. SQL Server A and SQL Server B are the same version, 2019 but something is causing these jobs to fail. I’m not sure what to do next. Any thoughts/suggestions would be greatly appreciated. Thanks.732Views0likes4CommentsSQL Server Config Manager Error "MMC could not create the snap-in"
Hi, I have seen this error elsewhere online. I have gone to mmc to enable the snap in and I still have had no fix. My computer is running Windows Server 2022, SQL Server Express 2022, and SSMS. I have reinstalled, repaired, and all of the other tricks. Help!Solved2.1KViews0likes3CommentsHow to create view joining two table of similar records without duplicating.
Hi All, Hope all are doing great. I have a small query regarding the Join function to create view. I have two table in which table 1 is having 40k records and table 2 is having 40k records. But when i am joining the both to create view, it is showing 47k records. Please note that i am combining table using two common column in both, one is "Calendar_Date" and one is "Personal_ID". In some cases few Personal ID has duplicate records for each month. So while creating the view the, these duplicate records gets multiplied . Hence the total records exceeds 47k. How to make it same 40k records which i am having in each table. Any help would be highly appreciated. Regards, SagarSolved559Views0likes4CommentsOpen reportserver webservice URL with https leads to an ERR_HTTP2_PROTOCOL_ERROR
We have installed on a Windows Server 2022 the latest version of PowerBI Reporting Server. We have bound a wild card certificate to the PBRS webservice and PBRS portal site. We have also added the FQDN cname to the PBRS reportingserver config file. We have used to deploy any reports by URL's likehttps://reports.contoso.com/ReportServer/Pages/ReportViewer.aspx?/Invoice/InvoiceReport. Opening with Microsoft Edge we get the error: Hmmm… can't reach this page It looks like the webpage athttps://reports.contoso.com/ReportServer/Pages/ReportViewer.aspx?/Invoice/InvoiceReportmight be having issues or it may have moved permanently to a new web address. ERR_HTTP2_PROTOCOL_ERROR On the other hand when opening the URLhttps://reports.contoso.com/Reports/Invoice/InvoiceReport we will be asked to login with the user credentials. Afterwards calling the webservice runs fine. Does anybody had already the same error and how we can avoid it?5.6KViews2likes10CommentsAssi9stance in a Sql statement
Hi all I have a Table and I want to retrieve the record with the latest Sequence for each code. I need some help to write a query. Thanks to help me out. Code Name Sequence Title J001 John 1 Junior Administrator J001 John 2 Administrator J001 John 3 Senior Administrator S001 Sue 1 Accountant S001 Sue 2 Senior Accountant R001 Robert 1 Manager My desired output J001 John 3 Senior Administrator S001 Sue 2 Senior Accountant R001 Robert 1 Manager350Views0likes1CommentHow to increase SQL query performance of a view?
Hi everyone, I am new to Microsoft community, so please let me know if this post is not in the right forum and if so which one would be the right one. issue: - Update & query (using Power BI) of my Sales Weekly View takes forever (>30min) and I would like to understand how I could improve this Current setup: - Sales Daily View: View containing aggregation and joins of two main sales tables and a date table - Sales Weekly View: View joining the "Sales Daily View", a sales table and two dimension tables and containing extensive logics (mainly aggregations) Please let me know if you have any idea how to streamline this and improve the performance of the view.53KViews0likes4CommentsForecasting with LAG() - NULL issue
Some Value Some Change Other Value ------------- --------------- -------------- x a% 41000 y b% 40750 z c% NULL m d% NULL k f% NULL I have data as shown. When the Other Value is NULL, I want to take the LAG value for Other Value and multiple it by the current rows Some Change Column. When I use LAG, it only populates the first NULL. When I get to the next row, LAG returns NULL but I want it to return what was previously calculated multiplied by the next percent in the Some Change column. For example: 1) 40750 x c% (This works with LAG but the rest do not) 2) (40750 x c%) x d% 3) ((40750 x c%) x d%) x f% Is there a way to do this inline without populating a table and looping over the NULLs? Sample code to work with: DROP TABLE IF EXISTS #LAGISSUE; CREATE TABLE #LAGISSUE( ROWID INT, SOMEVALUE INT, PercentChange FLOAT, OtherValue int ) INSERT INTO #LAGISSUE SELECT 1,40000, .98254, 41000; INSERT INTO #LAGISSUE SELECT 2,41000, .9654, 40750; INSERT INTO #LAGISSUE SELECT 3, 42000, .92012, NULL; INSERT INTO #LAGISSUE SELECT 4, 43000, .9357, NULL; INSERT INTO #LAGISSUE SELECT 5, 43000, .8976, NULL; SELECT SomeValue, PercentChange, OtherValue, CASE WHEN OtherValue IS NULL THEN ROUND(LAG(OtherValue) OVER(ORDER BY ROWID) * PercentChange,0) END AS ForecastedValue FROM #LAGISSUE; DROP TABLE IF EXISTS #LAGISSUE; SQL gives the following results. How can I get row 4 to be 37495 * .9357 and so on?304Views0likes0CommentsNeed Help with SQL Server Express, Folder of CSVs and Power BI
Hello, I have a folder of CSVs that is updated daily. I want to get those into an SQL server and connect to Power BI. The reason I am going this route is Power BI currently just imports the CSVs and combines them, but it is killing the performance while working in Power BI Power Query. What is the best way to load and combine the files into SQL Server Express so I can connect the database to Power BI?Solved742Views0likes2Comments