Skip to content

Tag: sql

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…

Conditional Query Using “AS” field

Above you can see my code. It is currently returning exactly the output I want when you remove the “WHERE” function. I’m adding the “WHERE” function and attempting to access the new column I made called “NPO”. It seems as if the column does not exist to the SQL editor…

SQL Lag() to Find Datetime Difference

I am trying to find the difference between Datetime entries in my sql table and was following this article – https://blog.jooq.org/2015/05/12/use-this-neat-window-function-trick-to-calculate-time-…