Tag: sql

Existing SSIS Package conversion to point to Azure SQL Data Warehouse

Migration of on-premise SSIS packages to Azure SQL Data Warehouse. Can someone suggest references or ideas/steps involved in modifying existing SSIS packages that loads a on-premise sql data warehouse to populate a SQL Data Warehouse? Is this possible? Regards, KK

Query to match products to customers?

We have a wide variety of products, with many added each day. Customers can sign up for an email alert. These is sent in bulk each evening, with customers receiving a bespoke list of products that match what they are looking for. There are three relevant tables in the database: Accounts (pk_AccountID,EmailAddress,Title,Name) Accounts_Alerts (fk_AccountID,pk_AlertID,Category,MaxPrice,Colour) Products […]

T- SQL Update Issue

There are two Tables A and Table B Table A Date Budget 9-1-2016 21 9-2-2016 10 Table B Date Amount Budget 9-1-2016 12 9-1-2016 15 9-1-2016 17 9-2-2016 15 9-2-2016 10 9-3-2016 12 I want to divide the daily budget in Table A to the corresponding items in Table B as follows: Date Amount Budget […]

Eliminate duplicates based on Order By SQL

I have a table with more than 20 columns and more the 300.000 rows out of which the relevant columns for my question are the following: column1 |column2 |column3 | date 123 | 657 | 2222 | 20 dec 123 | 658 | 2222 | Null 124 | 543 | 3333 | Null 124 | […]

Batch deletion correctly formatted?

I have multiple tables with millions of rows in them. To be safe and not overflow the transaction log, I am deleting them in batches of 100,000 rows at a time. I have to first filter out based on date, and then delete all rows less than a certain date. To do this I am […]

Correct sentence SQL

COL. A& B OREADY INSERT My sample data: A B K P M — — — — — 2 5 3 5 Query: select ([A] + [B]) AS [K], ([A] * [B]) AS [P], — can I write like this? ([P]-[K]) AS [M] — or must I write : — ([A]+[B]) – ([A]*[B]) /* sometimes […]

How to do order by and group by in this scenario?

I need to select TOP 3 Sports based on TotalUsers by DESC and group them by Individual Sports. What I’ve done till now is SELECT * FROM ( SELECT R.Sports, R.RoomID ,R.Name, COUNT(C.ChatUserLogId) AS TotalUsers, ROW_NUMBER() OVER (PARTITION BY R.SPORTS ORDER BY R.SPORTS DESC ) AS Rank FROM Room R JOIN ChatUserLog C ON R.RoomID […]

Group By 'Then' Statements

I can’t seem to figure out how to make this report combine the two numbers for DRML. Right now it is giving me 5 rows when I need shelter and LSCC to be combined. What am I doing wrong? SELECT SUM(service.ServiceTotal) as servTotal, CASE WHEN ProgramName = ‘Crossing Operations’ THEN ‘Crossing’ WHEN ProgramName = ‘Shelter’ […]

Query against a view under master database is much slower than query directly under specific database

I am not sure whether there exists a general answer before I give more details. For exmaple: I have a view named vw_View I tried the following two queries to get the result: Under master database select * From [test].[dbo].[vw_View] Under test database select * From [dbo].[vw_View] Could anyone tell me why query against the […]

Count concurrent dates in user-input date range using SQL

The user will input a date range, and I want to output in SQL every date between and including that range in the number of concurrent uses of said equipment. In this example, the user date range is 03/08/2016 to 03/09/2016, so you can see below I include anything on or between those dates (grouped […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.