I have tables with primary key uniqueidentifier type and add non sequential ids, now I want just to start adding only sequential ids in this tables. The guid generation is made in the code. Is it possible this to create problems in the indexes of the previous data. Logically I don’t see any problem, but…
Tag: sql-server
SQL: Delete XML node in an UPDATE statement
I keep getting this error: In search of a solution to this answer I came across this SO article about updating in a SELECT statement: How do I UPDATE from a SELECT in SQL Server? Example… Note: the field CustomProperties is nvarchar(max) which I convert to xml. I also tried a cursor (nasty things), but …
Show Unique values only
I am using SQL Server 2019 and looking for a way to show ONLY the latest value for each AOC based on its latest FW_Version. Here is my query I have so far but this shows everything: What I would like to show ONLY items marked in yellow… How can I make this happen? Here is the list of my
SQL – Calculate number of occurrences of previous day?
I want to calculate the number of people who also had occurrence the previous day on a daily basis, but I’m not sure how to do this? Sample Table: | ID | Date | +—-+———–+ | 1 | 1/10/…
Find value that can be 0 or can be greater than 0 but must have at least one record equal 0
I need to find records that equal 0 and have other records that are greater than 0. The result should have at least one record that equals 0 and must also have at least one record that is greater than 0. It is easier to explain it with visuals: It should not look like: I have tried this: Sorry if
Inserting rows based on conditions
Table Name: CaseHistory I’m currently working with a dataset that aims to offer insights on customer support cases on a weekly basis. In the example above, you can see the progression of case 123376 from Week 1 till Week 5, amongst other cases. What I would like to be able to do is insert a row for a ca…
Date compare and difference
I have “Employee” table with employees’ “StartDate”. I want to get a list of all employees who are reaching their work anniversary next month. So far I have reached up to this point: …but this doesn’t seem to be working. Answer I want to get a list of all employees wh…
Finding voters that did not vote in an election through a many to many relationship with MySQL
I have two tables linked through a many-to-any relationship. Table one contains all voters with an ID, table two contains all elections with an ID, and table three links both tables using their IDs. …
How to get the actual script of a stored procedure in another server?
I use SQL Server 2017. I have linked a serverdatabase to another my main database. So, if I execute the query below, it works and brings me the correct data: What I want to do is to get the actual script of a stored procedure from the linked database. Assume I have the stored procedure: sp_GetNumbers, then I …
sa can’t ALTER USER in SQL Server
I’m trying to run an alter user command as sa in SQL Server: However when I do so I get this error: Msg 15151, Level 16, State 1, Line 1 Cannot alter the user ‘MyAppDemoAdmin2’, because it does not exist or you do not have permission. I see that the user does exist in the user list, so I mus…