Skip to main content

All Questions

Tagged with
1 vote
1 answer
72 views

Query to generate payroll based on attendance for a month

I have written a query to generate payroll based on attendance for a month, for about 4000 employees. It takes quite a long time to execute. Basically, what I am doing is to joining two different ...
Parvez's user avatar
  • 23
3 votes
1 answer
1k views

Inserting data into SQL-Server table dynamically

I know I can do all this via SSMA quite quickly, but I wanted to see if I could do it efficiently in PowerShell myself as a little project. Basically, the entire script takes tables from an Access ...
Owain Esau's user avatar
7 votes
0 answers
155 views

Modeling tabular structure in MSSQL to store data like Excel sheet applying Column inheritance

I've created this database structure to store tabular information (it's a simplification of my real structure but enough to show the point). In it I have Sheets and ...
Guillermo Subiran's user avatar
3 votes
2 answers
98 views

SQL Server - Iterate, aggregate, and insert

I'm trying to find an efficient way to aggregate data for reporting. Let's say I need to aggregate the following data in 5-second intervals: ...
Jake Reece's user avatar
2 votes
1 answer
109 views

SQL Query to check if 100+ (or Dynamic) columns in table is null

Let assume a table has more than 100 of columns & I want to display all the rows when all of its columns (Col1, Col2, ..., ColN) are nulls except for the column(s) I mentioned (PK). This is just ...
DxTx's user avatar
  • 123
1 vote
2 answers
61 views

Displaying a single record based on DocID

I have a table with ~900,000 records. I need to display a single record based on DocID using this query. The record is the latest record that got modified by another program. This piece of query run ~...
SIRS's user avatar
  • 143
2 votes
3 answers
81 views

search for text across multiple tables

I've got the following query. ...
Pauly N.'s user avatar
0 votes
1 answer
1k views

T-SQL query outer apply with nested subqueries

I have the following 3 tables, and I don't have the option to modify them. [Logs] table with [log_type], ...
Thomas Hsieh's user avatar
-1 votes
3 answers
83 views

Insert to table from a temporary table [closed]

I created a procedure involving dynamically collecting from various projects (databases) some records into a temporary table and from that temporary table I am inserting into a table. With a ...
BinaryTie's user avatar
  • 157
1 vote
1 answer
52 views

Remove table variable from query

I am running this query, and to get the calculation that I need, I use a table value parameter to house some of the data. Scanning roughly 50K rows to create the table value parameter then performing ...
BellHopByDayAmetuerCoderByNigh's user avatar
2 votes
1 answer
113 views

Optimising performance of long running a sql query

The code below takes 5-6 hours for a years worth of data (850,000 records). It takes much less time when running a single month. To start with is there anything glaringly obvious within this script ...
Simon's user avatar
  • 149
3 votes
1 answer
119 views

Storing user permissions to hierarchically structured data in SQL Server

I'm developing a system that supports creating accounts and multiple users within every account that can each access a certain subset of data of their "parent" account. The data is stored in a SQL ...
Andre Borges's user avatar
4 votes
2 answers
66 views

Acquiring earnings information

The first part of the query grabs Policy's Premiums, Effective and ...
Oleg's user avatar
  • 41
1 vote
1 answer
95 views

Correlated subquery slow

I have a table that looks like this Directory nvarchar(max) Extension nvarchar(10) Length bigint I also have another table that provides the type of file (lookup table) extension nvarchar(10) ...
VinnyGuitara's user avatar
2 votes
1 answer
73 views

Demographics information for EDI report

I am going through some of my companies EDI reports to see if I can make them faster. The query below runs in less than one second in our AWS RDS environment, but it takes ~55 seconds on a blade in ...
Jeff.Clark's user avatar

15 30 50 per page