Monday, March 18, 2013

[SQL Server] a query like factorial

[SQL Server] a query like factorial


a query like factorial

Posted: 18 Mar 2013 05:00 AM PDT

Hi.I ask you for help because its more than 2 days im thinking about this question.Imagine we have a table like this:ID | Value---------1 | 192 | 903 | 204 | 85 | 9I want my query make this output:ID | Value---------1 | 192 | 19 + 903 | 19 + 90 +204 | 19 + 90 +20 + 85 | 19 + 90 +20 + 8 + 9I already tried so many queries, the last query I wrote are this but it dont make correct output:[code="sql"] WITH CTE (rowNum,Value,Level) AS( SELECT ROW_NUMBER() OVER (ORDER BY ID DESC) as rowNum, Value 0 as Level FROM Mytable WHERE ID = (SELECT MIN(ID) FROM Mytable) UNION ALL SELECT ROW_NUMBER() OVER (ORDER BY ID DESC) as rowNum, Value Level + 1 FROM Mytable a INNER JOIN CTE b ON b.rowNum <= a.rowNum + 1 --a.rowNum are not allowed here )SELECT rowNum, SUM(Value)FROM CTEGROUP BY LEVEL, rowNum[/code]Thank you for help

Alpha character in SPID? Disk I\O Bottleneck Troubleshooting.

Posted: 07 Mar 2013 03:42 AM PST

Hi.OS is Server 2003 R2 Enterprise Service Pack 2.SQL is Microsoft SQL Server 2005 - 9.00.3353.00.I was tasked with troubleshooting the following repeating error:[code="plain"]Source spid4sMessageSQL Server has encountered 30 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\DataBase_data.mdf] in database [DataBase] (8). The OS file handle is 0x00000960. The offset of the latest long I/O is: 0x000000d80d8000[/code]However, I don't know how to troubleshoot "spid4s".What is the alpha character 's' doing in the spid?There spid is just the session ID, right?Session IDs only have numbers.There is a session 4, but that's been asleep while the error has happened.It's happened multiple times while I've watched it because of 'SPID4' which I can't even investigate.Can anyone shed some light for me?

No comments:

Post a Comment

Search This Blog