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

39 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
137 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 ...
6
votes
0answers
596 views

T-SQL Hmac (Rfc2104 SHA2_256) Implementation

I'm trying to implement an Hmac in T-SQL using this question as an guide. Please critique this: ...
5
votes
0answers
126 views

Find unused stored procedures/functions in SQL 2012

I was given the task of finding those unused procs/functions in our SQL 2012 database. Initially my plan was to use the table sys.dm_exec_procedure_stats. I could set up a job to check the table ...
3
votes
0answers
25 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 ...
3
votes
0answers
79 views

Query for a ticket system involving cases and casts on many attributes

I have this SELECT statement that inserts into a temp table and it is slow! Right now it takes ~1500 ms to run and only deals with ~7000 rows. As the data grows ...
2
votes
0answers
39 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 ...
2
votes
0answers
69 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: ...
2
votes
0answers
39 views

Generalizing work orders

I am working on designing tables for work orders. The problem: There is different work order models (from now on called WOM) The WOMs share some attributes (Num, Date, Description, ... etc) The WOMs ...
2
votes
0answers
57 views

Complex views are a little slow

I have this view vw_RFQPartVendor that's based on these two views vw_requestVendor and ...
2
votes
0answers
7k views

Mapping Excel columns to table columns, then processing data

I have written some code for mapping excel columns to table columns and processing data after mapping columns. Please review this code, check for SOLID, OOP principles and suggest any improvements and ...
2
votes
0answers
485 views

Generic polling class and using it to poll SqlConnection

I have the following poller class that can be used to "poll the required action": ...
2
votes
0answers
27 views

Generating days in a specific range

I have a query in MSSQL, where I get a summary by days from a range in a table, and this is in union with other queries. This query is used to generate days in a specific range, then add the registry ...
2
votes
0answers
121 views

Annualized Turnover Report

What can be made better? How ugly is my code? If it's terrible, where can I improve? ...
2
votes
0answers
358 views

Insert all SQL Server table rows in a Google BigQuery Table

I want to know the best way (best performance and reaction time) to insert all rows of an SQL table into a Google BigQuery table. Actually, I am looping over a query result and insert the rows one by ...
2
votes
0answers
1k views

Installer package using Inno Setup

I'm building an installer package for our software using Inno Setup. As a part of this, I'm also building a few different DLL's in Delphi XE2 to accommodate for some of the common tasks required by ...
1
vote
0answers
23 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 ...
1
vote
0answers
24 views

Log table with a summary of claims

I'm writing a log table which contains the summary of the claims. The log table logs the data whenever there is an upload. I have written the following SQL query. Though it serves the purpose, I'm ...
1
vote
0answers
22 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: <...
1
vote
0answers
122 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
vote
0answers
23 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 ...
1
vote
0answers
165 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
0answers
122 views

Exposing LocalDB API to VBA

SQL Server has had LocalDB since 2012. The main primary purpose for the LocalDb is to support developers without requiring a full install and running a service. However, a LocalDb can be also used in ...
1
vote
0answers
420 views

Selecting coins with alert count by using a subquery

I have a table called alerts and is related to a table called coin (coin can have many alerts). I would like to return a list of alerts but also return a subquery count of how many alerts that coin ...
1
vote
0answers
52 views

CF/SQL Query using window functions

I am very new to MS SQL Server and am trying to learn how to combine window functions within my SQL query. I have two tables that I have to tie together using assoc_id and associate so that I can set ...
1
vote
0answers
62 views

Win-Loss Record in SQL Server

I'm building a database on Microsoft SQL server to teach myself SQL. I am a big UFC fan so I'd like to build a database on UFC fighters. I'm building two tables [fight] and [fighter]. The [fighter] ...
1
vote
0answers
31 views

SQL Server: Lock rows on updating

I have multiple instances of an application (C# console apps) which needs to pick a set of records from a table and mark them (Update AllocatedTo with instance name), so that no other instances will ...
1
vote
0answers
43 views

Searching news for a string value

I need to improve performance for query ...
1
vote
0answers
73 views

SqlCommand filter by dates are slow

I have these codes(.net framework 2.0): ...
1
vote
0answers
34 views

Exclusive row lock

I'm in a situation where I need to manage a kind of FIFO process within a SQL procedure. The procedure is called by a multithreaded windows application. I've created a table which look like this: <...
1
vote
0answers
512 views

Current .NET session username injection in SQL Server stored procedures

I have a legacy WCF service that is ported from a security model using database logins and roles to a custom security. One effect of this change is that stored procedure are no longer executed using ...
1
vote
0answers
794 views

WCF service architecture when SQL Server direct table access is not allowed

Part of my job is to maintain an old application written in Silverlight talking to a WCF service which in turn fetch/persist data into a SQL Server database and in a BI cube. Most of the security is ...
1
vote
0answers
163 views

Stored procedure to compare stored procedure result sets

Originally posted as an answer to a SOF question, this is about a generic procedure that allows back-end developers (e.g. SQL developers) to compare the results sets obtained by running two procedures ...
1
vote
0answers
179 views

T-SQL Totp (Rfc6238 SHA2_256) Implementation

Using my previous function as a base I've come up the following: ...
0
votes
0answers
63 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 ...
0
votes
0answers
21 views

SQL Server - Flagging overlapping time entries and calculating time without overlaps

Here's my example set up in rextester. https://rextester.com/LROA87361 I have the following table in gray (the rightmost 2 columns are for explanation). As you can see an employee's time entries ...
0
votes
0answers
47 views

Parties and Messages in SQL e-Commerce db design

I'm posting a follow-up question based on my first question. My goal is to, as an exercise for myself, create a complex (in my opinion) e-commerce application. The explanation of the application can ...
0
votes
0answers
25 views

Ensuring referential integrity in child, group relationship

I'm not going to lie - Sql Server is not in the top 10 of my skill set, but it's something that I have to do from time to time. What's more, I'm using Entity Framework, so there is a workaround ...
0
votes
0answers
20 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
26 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? ...