Skip to content

Tag: sql-server

SQL query on certain database names

I currently have many databases on a server. I want to run a query on only databases that end in “AccountsLive”. Not all of them end with this, so I kind of want to do a wildcard %AccountsLive query and not using a WHERE NOT name IN(‘master’, ‘tempdb’, ‘model’, …

Conditional Aggregation query not giving correct output

I am trying to find average using conditional aggregation. I have 2 tables in SQL as below RentalExtension Table: RentalItemsID ExtensionDate ExtensionBy_UserID 7 2020-07-27 10 1 2020-07-28 7 The user table contains attributes as listed in select query When I run the query above I get Extension Rate for UserI…

Store hourly data efficient way

There is a requirement to store hourly data in SQL Server 2016 and retrieve. It’s an OLTP database. I will explain with an example: we need to capture temperature of each city of a country and store on hourly basis. What would be the best and efficient design to do this. The data would be stored for a y…

How can I use Except all in SQL Server?

I’m trying to use this query statement in order to except daysoff and a duration, let’s called holiday from a calendar of a specific month . This what I have tried : and this is the function of Get_Calendar_Date To except the daysoff ( weekends ) , I have used except , but what I got is something …