Skip to content

Query to update duplicates

I have the following query that returns duplicates that i am running on sql server. So I need to write a query that will update second instance of the email address based on the select query that retrieves dulicates to for example imports@rohnis.com to imports@rohnis.com.duplicate. If it is info@eps.ws then i…

Grant connect to all DATABASES

I’ve seen there’s a way to grant select to all tables within a database, however I can’t seem to find a way to grant connect to all databases. I can’t manually do: so on so forth, as I have many databases. Is there an equivalent to something like: GRANT CONNECT ON DATABASE * TO readonl…

How to calculate a group average in SQL?

I have a sql data set which look something like: I would like to be able to select the data in such a way that the query will return: With the average result calculated over the 3 years shown for each person. How could I achieve this in SQL Server? Answer I think you want a window function: