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
1 vote
1 answer
638 views

Insert multiple rows without using CURSOR SQL Server 2014

I have a fairly complex query which insert multiple rows into a table from multiple tables. Its works fine but I really don't want to use cursor as some blog says cursor took long time for execution (...
Parvez's user avatar
  • 23
3 votes
2 answers
761 views

SQL Query - records within the last year

Bit of a complicated one for me. I have a database full of hundreds of thousands of records, many of which are duplicated. I need to get all records within the last year but making sure every ...
Matthew Stott's user avatar
1 vote
1 answer
1k views

Determining daylight-saving time in Central European Time

(We are on SQL Server 2008). The following constellation: Our applications passes date&time around (in the most horrible way possible). We want to simplify this. Instead of a culture-specific ...
Quandary's user avatar
  • 159
4 votes
1 answer
99 views

Get local datetime from UTC time

One of the app is inserting date in UTC format (column CreateDate). When reporting from this table, I used a difference in hours between the inbuilt ...
Ashish Gupta's user avatar
2 votes
1 answer
410 views

Validating region/state/province codes for different countries

I have a large table in which I store region/state/province codes (two letters) from different countries. I use these region codes further downstream for multiple process. One of the steps I do is a ...
VK_217's user avatar
  • 141
3 votes
1 answer
150 views

SQL SP creating certificates for shipping

We ship large spools of copper wire and pallets of copper rod that have to meet specific chemical and mechanical requirements, this is what must be put on the certifications. I created an SP which ...
Mike's user avatar
  • 185
0 votes
1 answer
57 views

Updating 3 columns conditionally on a database table

I need to run this script to update the value of 3 columns based on certain conditions. Right now, this is what I have: ...
João Pinto's user avatar
3 votes
1 answer
81 views

Loop Through bitarray to retrieve subsets of that bitarray

Objective: I want to loop through a bitarray and store subsets of that bitarray in a table. Context: I have a bitarray with 48 elements where each element represent one hour. I want to look back 24 ...
RMSPereira's user avatar
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
1 vote
1 answer
108 views

SQL Stored Procedure to export specified data

I'm currently using a stored procedure(sproc) to export to Excel. The sproc is being passed ...
Jaskier's user avatar
  • 111
1 vote
1 answer
279 views

Calculate NPS in a stored procedure

We collect customer surveys and one of the questions is the dreaded "How likely are you to recommend our service?" question from which we calculate a Net Promoter Score. (I hate this calculation, but ...
FreeMan's user avatar
  • 1,290
4 votes
1 answer
143 views

Retrieving a product's sold quantity

I've written a view to retrieve each product's sold quantity and four week sales average by Branch/Route/...
Shelby115's user avatar
  • 1,961
6 votes
2 answers
119 views

Find how much reputation a user had on a given date

I saw this question on MSE and went ahead and wrote a solution to it: https://meta.stackexchange.com/questions/313561/determining-users-reputation-as-of-particular-date This calculates the ...
Magisch's user avatar
  • 330
0 votes
1 answer
73 views

Filtering query by date built from integers

I am trying to make a stored procedure and pass some parameters for filtering. As soon as filtering is in horizon, code has to be as generic as possible with as few as possible ...
sensei's user avatar
  • 286

15 30 50 per page
1 2
3
4 5
14