All Questions
84 questions
0
votes
2
answers
45
views
Table-Value Function with row-level-locking
I'm implementing row-level-locking on a MS SQL Server. The function I created below works, but even with a very small data set, it takes a significant amount of time to return the results.
If I were ...
1
vote
1
answer
129
views
Get average post score of TOP 10 tags on StackOverflow using Stack Exchange Data Explorer
I want to use the Stack exchange data explorer in order to display some basic information about the top tags.
The query should print the number of questions and answers, the average number of answers ...
3
votes
1
answer
154
views
Deleting millions of logs in batches
I have a fast growing table with logs that I frequently have to delete (the server doesn't have much resources). It grows by at least two million entries every day. The database is a SQL Server 2012.
...
3
votes
1
answer
255
views
Calculating all flight connections
I am working on an API to return all the possible flight route between point A and B. I have a set of data which includes the flight number, airline, departure airport, destination airport, departure ...
1
vote
1
answer
83
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 ...
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 ...
2
votes
0
answers
81
views
Insert items from one table that do no exist in the other one [closed]
The insert query below must insert the items not present in the Articolo table by importing them from Importazione, and must update the items in the Articolo with those present in the Importazione. To ...
2
votes
2
answers
2k
views
Stored procedure to implement a search filter
I've implemented a stored procedure for a search process SQL Server 2008. I'm not sure if everything I created is correct. Also I'm wondering if this code has any leaks or vulnerability on SQL ...
2
votes
2
answers
60
views
Query to find instances of two types of events occurring more than one second apart
I have 3 tables on my database: BusinessObject and CustomEvent, and EventType. ...
7
votes
0
answers
164
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 ...
1
vote
1
answer
60
views
Ledger query using window functions
This is a ledger kind of table, initial amount is when the movement is null and all transactions on it is based on the Waste_Seq
the query take the last entry (id) based on the movement and change ...
6
votes
1
answer
5k
views
Fastest way to insert rows in mysql vs sqlserver (large dataset)
I'm looking for any possible improvements that could be made to run the mysql piece of code faster.
I created a simple test winform application that creates two docker databases :
Sqlserver on linux ...
3
votes
2
answers
101
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:
...
3
votes
1
answer
141
views
SQL query to check if 100+ (or dynamic) columns in table are null
Let’s assume a table has more than 100 columns and 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 a ...
1
vote
2
answers
75
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 ~...