2022 Developer Survey is open! Take survey.

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).

Filter by
Sorted by
Tagged with
1 vote
1 answer
31 views

batchUpdate using pdo and MSSQL

...
user avatar
  • 205
0 votes
1 answer
49 views

Creating database and two tables linked by foreign key

These commands do what I want, but I'm trying to find out the best approach for this. My main areas of concern are: error handling and disposal of resources. In regards to error handling, I'm catching ...
user avatar
0 votes
0 answers
64 views

write data as feather file given sql script from sql server in python and windows

I am currently using this "pattern" to write feather files to my local windows machine using python: ...
user avatar
  • 631
0 votes
0 answers
45 views

SQLite loses performance versus SQL server and powershell regarding LEFT JOIN (INTERSECT)

I have the following files in a directory: 1256590_hashed.txt 1273301_hashed.txt 1177301_hashed.txt ... etc... these represent cut and hashed segments of documents ...
user avatar
  • 1
6 votes
0 answers
127 views

dotnet - creating db records in bulks in a background job

UPDATE: I found the namespace Channels, and this does exactly what I want to do, but in a much more stable way. Please don't use my code for anything important! :) Use case I have a site that (at peak ...
user avatar
-2 votes
1 answer
46 views

T-SQL Query Performance [closed]

The query below already has indexes based its execution plan but it is still under performant with larger datasets. Are the additional null checks needed and why? Do you see anything that can be done ...
user avatar
  • 35
1 vote
1 answer
162 views

Database schema for discussion forum scraping

I'm scraping posts from various discussion forums and storing those posts, along with some metadata, into a relational database (SQL). My actual use case is a bit more complex, but I think I can give ...
user avatar
0 votes
2 answers
32 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 ...
user avatar
  • 181
1 vote
1 answer
203 views

Get result of a scalar-valued SQL function from C#

I do not receive files on holidays; I only receive files on regular days—i.e., non-holidays. I want to skip 2021-09-06 since that's a holiday (Labor Day) and I know I will not receive any files. ...
user avatar
-1 votes
1 answer
59 views

IF SELECT statement will break SQL ACID Compliance? [closed]

My QA told me that I should not use IF SELECT before doing an UPDATE statement because it will breaks the atomicity of a ...
user avatar
  • 141
3 votes
2 answers
61 views

Alter authorization on all non-system SQL Server databases

I am not very experienced with T-SQL and feel this can be done better. The script changes ownership of all "user" (non-system) databases to sa. Usage of a ...
user avatar
2 votes
2 answers
49 views

Complex reporting query suggestion needed for different approach as per latest Tsql format

We have recently migrated from SQL Server 2008 R2 to SQL Server 2017 web edition. I am not a SQL developer but enthuses to learn. Since many of our scrips are of old SQL format, I am searching for ...
user avatar
3 votes
3 answers
100 views

Retrieving restaurant orders from SQL Server [closed]

...
user avatar
3 votes
2 answers
156 views

PySpark SCD Type 1

I am using PySpark in Azure DataBricks to try to create a SCD Type 1. I would like to know if this is an efficient way of doing this? Here is my SQL table: ...
user avatar
  • 31
1 vote
0 answers
23 views

Re-organizing indices in case of fragmentation is T-SQL

In order to keep the fragmentation ratio of indices low, you should re-organize the indices from time to time on MSSQL. Microsoft describes in the link below how you can check the fragmentation of ...
user avatar
5 votes
1 answer
182 views

Basic schemas for database and tables creation, bulk import from .csv and basic queries

The following SQL code serves the purpose of assessing basic SQL Server literacy. I am creating database and tables schemas, inserting data from .csv files. Constructing 8 simple queries as answers to ...
user avatar
0 votes
1 answer
133 views

SQL Query to perform a "reverse exclusion" on a LEFT JOIN with a select from the left side table

I have a set of tables that I want to execute a LEFT JOIN on and bring back "excluded" rows. In addition, I would like the left table's ID included as ...
user avatar
  • 101
1 vote
2 answers
110 views

Optimizing database access using LINQ [closed]

I have the following method that I am trying to optimize. Currently, the method works great, however, it takes a little over 3 hours to complete. I feel like, using some nifty LINQ joins, it should be ...
user avatar
  • 188
1 vote
1 answer
90 views

Retrieve data from two different rows in a single SQL query?

I've a table with the following data and I need to find the number of minutes between two jobs (Say A and C). The following query works but wondering, if there is a simpler way to achieve the same. <...
user avatar
  • 163
3 votes
2 answers
97 views

all appointment based on interval distance

Currently with a given Date and an Interval in Day, I can calculate all of the appointment in the future. for example if you are ...
user avatar
2 votes
0 answers
36 views

Basic login by username logic with SQL Server

My goal is to make a very simple library with the authentications basics: create a user and save its hashed password, change its password, have a method to check if the password is correct for login. ...
user avatar
2 votes
1 answer
154 views

How to make this query better (e.g. avoid repeating subquery in a query)?

Stack Exchange provides access to query their MS SQL databases. They have a table Posts where each post is either a question or an answer (see the schema on right ...
user avatar
  • 121
2 votes
1 answer
36 views

Performance stored procedure update multi-coulmn sql

I have a stored procedure the every 5 min run in sqlserver high cost iO/cpu do you have any idea to tune this query ...
user avatar
2 votes
2 answers
116 views

Receive data from SQL and CSV and send it to MySQL database using Python

Details: I have a code, which does the following: Get data from CSV and insert it into MySQL table Get data from SQL Server and insert it into MySQL table Run this code every 240 seconds - to ...
user avatar
  • 53
1 vote
0 answers
29 views

Code for tracking changes and deletions to tables

I have written a SQL server stored procedure to generate "log" tables which store the old values of rows when a table is updated, and also record when rows are deleted ( and by who ). It's quite ...
user avatar
2 votes
0 answers
40 views

API Layer ClientId and Security style

Im at the point where I am designing my api security and I was going with a custom attribute I don't want to use third party systems as they cost money. I was going to use the client id and the ...
user avatar
1 vote
2 answers
95 views

Faster/Better Processing for SQL While Loop

I have a list of about 55k Accounts that I am cleaning up. 95% of them are from US/Canada which is what I'm most concerned with. I am going through record by record and will perform various checks ...
user avatar
  • 211
1 vote
1 answer
31 views

Calling a function within stored procedure to derive a value

I am trying to write a sql storeprocedure that basically returns a derived value from an outcome of a function call. The derived field returns the difference in days and if the difference is less ...
user avatar
  • 197
1 vote
1 answer
96 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 ...
user avatar
  • 129
3 votes
3 answers
391 views

Export sql data to xml and csv

I have the below code that takes the sql data and exports it to xml or csv. The xml is processing at good speed but my csv sometimes takes 1 hour depending on how many data rows it exports. My ...
user avatar
3 votes
0 answers
368 views

Creating SQL Server Database Users Dynamically from User Input

The Application I have an application in testing that runs off of an MS SQL Server database. The app allows users to authenticate using Windows authentication (that is, using the Windows username the ...
user avatar
5 votes
1 answer
130 views

Excel to SQL server

I am self-taught when it comes to coding. I want to improve, so please give me advice if I have some bad habits or if there is in general a better way of doing this. The idea of this code is to look ...
user avatar
5 votes
2 answers
143 views

NewSequentialId - pure net core 2.2 implementation of sql server function

i'm currently trying to rewrite sql server newSequentialId() function in pure c# that is performing as fast as possible and eats minimum memory. Question is can I it be done better - current ...
user avatar
2 votes
1 answer
94 views

Reading customer data

This is the first time I am writing R code to access/manipulate and save data. The SQL query I would normally run then save to a spreadsheet, read it into R, save to another sheet then copy and paste ...
user avatar
0 votes
0 answers
751 views

Chart.js - Getting data from database using sql server and asp.net mvc5

I displayed and styled the chart.js and am also using mock data in the array, I just can't get my head around how to populate the data in the chart.js using MVC 5. I have tried lots of different ...
user avatar
2 votes
1 answer
1k views

Database Model for Feedback Module

I wish to generate an online feedback system. Requirements are Admin can enter feedback questions Admin will select these questions and create a feedback session One Question can be used in many ...
user avatar
2 votes
2 answers
2k views

Cancel Long Running Query using Cancellation Token AND SqlCommand.Cancel()

I need to be able to cancel a long running query programmatically through our application. The code below will kick off a long running query and give control back to the main thread. At any ...
user avatar
2 votes
0 answers
49 views

SQL Code That Looks for Dupes with Confidence Score, 3hr / 1.2 BILLION Rows Returned. Optimize?

OK, I have a customer list that has approx 80k records. I need to search and compare looking for duplicates, but duplicates could be an exact match, or a similar match (only some data matches) so it ...
user avatar
  • 211
1 vote
0 answers
29 views

Searching for Duplicates in SQL Table with Confidence Score

Sometimes I'm not sure if my questions should be here or StackOverflow, so I appologize if this is the wrong place. I have a SQL (MS SQL 2016) stored procedure that is evaluating data looking for ...
user avatar
  • 211
0 votes
1 answer
75 views

database connection, fetching rows and handling error in csharp

Fetching database records and displaying as JSON. Asking for revision to ensure if everything's ok, i.e. connections are properly handled and closed in case of error. ...
user avatar
5 votes
2 answers
193 views

Query with multiple foreign keys to the same table

I have a primary table, REP_ASSIST.ES_LOG with multiple columns that are foreign keys to another table, ...
user avatar
  • 217
4 votes
2 answers
175 views

Function to get current value or default from a string of two values

I have SQL scripts that I want to be executable directly in the editor (like DataGrip or SSMS) and also in automated integration tests. However, in each use-case they require different environment and ...
user avatar
  • 43.8k
7 votes
1 answer
81 views

Zombie killers ranking

Code Review has a Zombie Problem and, in comparison to The Walking Dead TV Show, our survival doesn't depend on killing them all day every day. As a potential solution, I though it would be ...
user avatar
  • 12.2k
3 votes
1 answer
72 views

SQL Sub-query with running total optimization

The codes below get the rows of data until it reaches the total running quantity limit. Notice that the SQL uses sub-query. ...
user avatar
  • 133
1 vote
1 answer
28 views

T-SQL Getting Sequential events with first even criteria

I have a query I am writing where I want output if a person has some service provided, then I want all the services they had provided after that and I don't want the individual returned if that is the ...
user avatar
3 votes
1 answer
647 views

Daily SQL job to delete records older than 24 hours

Below is a delete job to delete 1M+ records daily and takes 13 hours to complete and sometimes more than that. I need to optimize this. The table tblcalldatastore is being inserted 24*7 through a ...
user avatar
  • 43
3 votes
1 answer
141 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. ...
user avatar
  • 43.8k
1 vote
1 answer
37 views

Updating field in Temporary table

I have a more massive sp, in which I use some temporary tables, below is a part of the sp where I am updating a field in a temporary table two times. ...
user avatar
  • 119
3 votes
1 answer
131 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 ...
user avatar
  • 33
1 vote
1 answer
657 views

Do these BLL-DAL comply with the Dependency-Inversion Principle and is this valid Dependency Injection?

I am working on a very simplified proof of concept (POC). Separation of concerns should be achieved in this project, so that in the future we have flexibility in respect of what data source we use (...
user avatar
  • 497

1
2 3 4 5
12