Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sql-server]

Microsoft's SQL Server is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. It originated from the Sybase SQL Server codebase, which is why both products use the extension of SQL called Transact-SQL (T-SQL).

-1
votes
1answer
21 views

Bash Script sending data to Sqlserver using bcp sqlcmd performance and scale ability for future web API implementation

Goal: audit file existence and differences between two red hat Enterprise Linux Servers 5.11 (Carthage) If the files exist in both servers are they the identical? Check md5sum: If the md5sum is not a ...
-2
votes
0answers
14 views

SQL Query for cube : Tuning [on hold]

We are setting up a view based Cube, we are using MS-Sql server, But we are unable to process the cube, every-time the cube processing fails with Error: OLE DB error: OLE DB or ODBC error: Operation ...
0
votes
0answers
6 views

Dynamic “compilation” of SQL stored procedures

I have a stored procedure which is called to create ( "compile" ) temporary stored procedures, code below, based on whether a flag in a database record is set - the various sub-procedures such as ...
0
votes
0answers
16 views

Tracking when a column was last modified using a trigger (in SQL Server)

How can I improve the following code to track when an Azure SQL Database column value was last modified? ...
2
votes
0answers
25 views

SQL Database for Visitor Registration System

This is intended for a web-based application that allows someone to register visitors, assign their hosts, and indicate the dates in which they will be visiting. Imagine this scenario: I want to ...
1
vote
1answer
41 views

Upload csv file to sqlserver with python

I have to weekly upload a csv file to sqlserver, and I do the job using python 3. The problem is that it takes too long for the file to be uploaded (around 30 minutes), and the table has 49000 rows ...
2
votes
0answers
21 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 ...
0
votes
1answer
85 views

Modify a column in 2 tables based on trigger

This is SQL Server 2008r2. First, here are some tables and data for test: ...
1
vote
0answers
14 views

Calculate BACKLOG_M_1

I need to calculate the BLACKLOG_M value corresponding to the Snapdate of the first of the month. It becomes a constant value repeated for each line of the month As it is explained in the picture: <...
0
votes
0answers
119 views

Syncing a table to a remote database

I want to sync the table every few minutes to a remote database. I want it to be as efficient as possible. I wrote this stored procedure that will only return rows that are added or removed after the ...
-1
votes
1answer
35 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 ...
0
votes
1answer
33 views

Quickly check whether file name is in column in an SQL Table and move to new folder

I have a table that in one of the columns exists a list of file names. The names comes from other tables and the files in a folder. Not all the files are used, may be attached to parcels that no ...
3
votes
1answer
105 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 ...
1
vote
0answers
19 views

Activity grouping and selection according to order and completion requirements

The problem consists of two categories of events (Work and Rest) which together form a complete set. The number of Work events is open-ended. The number of Rest events is fixed at three (3). The ...
0
votes
1answer
42 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: ...
1
vote
1answer
36 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 ...
1
vote
1answer
106 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 ...
0
votes
1answer
71 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 ...
2
votes
0answers
65 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
0answers
58 views

One class for MySQL and MSSQL Queries

EDIT BELOW I am trying to create resusable classes for MSSQL and MySQL queries (later also Update and Delete queries). I tried it doing the OOP-way. Here is my result: Einstellungen.vb: ...
1
vote
0answers
144 views

Stored procedure that adds row-level auditing to a table

I'm looking for any suggestions on how to improve my T-SQL for this procedure. It works okay, but I'd like to get advice to improve it from more experienced SQL developers. This procedure adds 4 ...
1
vote
1answer
68 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 ...
0
votes
1answer
67 views

SQL Query to get parent parts of materials using Recursive CTE

The intent of the query is to filter out certain materials to get to a list that will then be run through a recursive CTE to drill up through the BOM to the 0 level assembly. P_Parts_CTE is filtering ...
4
votes
1answer
94 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/...
2
votes
2answers
88 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 ...
7
votes
2answers
94 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 ...
3
votes
3answers
233 views

Slow SQL Server performance with multiple PreparedStatement loop

I have a need to update thousands of database records at a time. I am using a loop to generate the necessary PreparedStatement updates, but am hoping for a more ...
1
vote
1answer
48 views

Worst Query performance issue on date calculation

I have a stored procedure that is taking more than 2 hours to complete and I noticed the below SQL is taking close to 25 mins for updating a million+ values.There are multiple steps like this and all ...
2
votes
2answers
44 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. ...
0
votes
0answers
51 views

ContactBook console based app

I wrote this simple contact book app. It helps the user to store and retrieve contact information. The app uses a SQL database server to store all the user data. One significant fact is that the db ...
4
votes
2answers
32 views

Select recordIDs for Bill of Materials

I have a hierarchy of parts in my database. For example, one part (call it 0010102-0112-315) is a resistor. It's used in a billion different top-level assemblies. ...
3
votes
0answers
63 views

Reading Database, scraping Barchart and uploading prices to DB

This is my first real excursion into Python, coming from C#. I wanted to see if my code is well-formatted and efficient. The following will read the needed codes from a Database Table, then submit ...
6
votes
0answers
108 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
1answer
37 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 ...
5
votes
2answers
115 views

Combining SQL Tables into One Table in New DB with Similar Fields

I have a SQL Server Database filled with Reports all having the same schema. What I've done is created a .NET application to automate the process of adding all reports to a new table. How can the ...
1
vote
2answers
102 views

Merge table stored procedure

I wrote a stored procedure that will do a merge of two tables: ...
4
votes
0answers
660 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
2answers
80 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: ...
2
votes
1answer
56 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 ...
0
votes
1answer
54 views

Query to show each sites stock transfer history between all other sites

The below query is used to return a dataset for a SSRS report. It works fine and is quick enough but I am looking for any improvements that could be made. The client has asked to see all transfers ...
1
vote
2answers
55 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 ~...
-1
votes
3answers
119 views

SQL query to classify and count logged messages

I have an SQL query that fetches some stats, and those stats are displayed on a dashboard. The dashboard runs this query every 15 seconds to fetch the most up-to-date data. The query is very CPU-...
4
votes
2answers
56 views

Inserting two rows that are almost identical to each other

I'm trying to make test data for an application I'm writing, and some of my test data is very repetitive, involving inserting a row and then inserting another row that is identical except for one ...
-1
votes
2answers
306 views

Insertion of big TXT file into Sql Server

The code posted below reads 500000 lines from a txt file and imports the lines read in a Sql Server 2014 database, the code works correctly but it takes too much time (even 40 minutes), especially ...
0
votes
1answer
54 views

SQL query to return a set of calculated values per site from multiple tables

I have written the below and am seeking any way that I could improve its performance. ...
10
votes
1answer
118 views

The seasoned Zombie sniper: a query to find unanswered questions with specific tags

The query (on SEDE) This query builds upon the previous and includes the suggestions by rofl as well as the now mentioned activity index. ...
11
votes
1answer
91 views

The sniper: a Zombie searcher for specific tags

Sometimes, it's not enough to know what the easy prey is. You also need to know whether you will be able to hunt it down. What good is an almost turned haskell zombie if you cannot read the functional ...
13
votes
1answer
1k views

A wounded Zombie finder, or: how to find the almost dead undead?

The Zombies are on their way to eat our statistics. Fortunately, we have a way to get rid of them: our votes. However, we need to find them first. The /unanswered section is too large and contains ...
3
votes
1answer
438 views

Implementing RecordSet-like class in C#

From the outset, let me state that I'm working with some older technology. I'd rather use Entity Framework, but I have to use what the client is using if I want to get paid. I am converting some old ...
1
vote
1answer
73 views

Query result as an HTML table

I am not a expert on php html. I built a website 2 months ago, and realized I using lot of php query result on web. Is there any approach without while my query result on multiple times ...