Skip to content

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 …

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…

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…