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).
-5
votes
0answers
12 views
How to get decrypted aspnet_membership password using sql query [on hold]
This is my query, but I do not get decrypted password.
...
12
votes
0answers
33 views
Cross-posts from Stack Overflow to CR
What this code does it explained in detail in the top portion of the query.
I have left out part of the list of language tags as I felt it was just noise. You can see the full collection here.
You ...
-4
votes
0answers
29 views
Finding rows where a bit column exists as 0 but not 1 [on hold]
The goal is to find any rows in someTable where there exists an entry for bitColumn being 0 but not having one where it's 1. I ...
12
votes
1answer
53 views
Query to count interactions between users
The source data represents interaction between people, some are internal, others are external.
The internals are recorded in the Users table (represented as the ...
7
votes
2answers
70 views
XML splitting query very slow
I have a query to split a delimited string into to multiple columns. The query is extremely slow and takes more than 5 minutes to handle 80444 rows. How can I improve execution time?
...
3
votes
1answer
57 views
4 database queries, multiple loops in loops, slow processing time
The octoberCMS(based on laravel) controller below is what I use to select the lowest price in 4 pricelists in the given daterange.
Prices can vary and it's not guaranteed that the more expensive ...
4
votes
1answer
492 views
Deleting millions of rows from a MSSQL server table
This SQL query took 38 minutes to delete just 10K of rows. How can I optimize it?
Index already exists for CREATEDATE from ...
5
votes
2answers
64 views
Using UPSERT to maintain word counts for subtitles
I will first explain the context. I want to read serie subtitles contained in .srt files. I have already done the part of extracting the words from the files (and how many times the word appears for a ...
4
votes
3answers
70 views
Central Database class
I have this web site I inherited as part of my job and it has some old code. I'd like to optimize it, but I don't really have the time to do it right, so I'm looking for some "low hanging fruit" to ...
4
votes
0answers
65 views
2
votes
1answer
83 views
2
votes
2answers
31 views
Sql Server: Getting the highest value based on two uniqueidentifiers - possible to avoid union?
I have two riscProfileTypeIds (both of type uniqueidentifier) of which I need the one with the highest sequence number
(the ...
3
votes
2answers
56 views
University Database
I am building a database for a hypothetical university. This is my SQL definition, with generated data added for my future use, such as demonstrating queries:
...
2
votes
1answer
125 views
DbGeography search query
I have a situation in which I need to get the closest road to a DbGeography point.
This takes 5 - 8 seconds to run in some cases.
I have a ...
1
vote
3answers
106 views
13
votes
1answer
92 views
Example script for teaching DDL and CRUD/DML operations
I have taught some SQL to others before, and I thought of making a script that has these attributes, for the purposes of teaching:
Fully functional to run on local DB instance with no fuss
Easy to ...
1
vote
1answer
38 views
Optimise MSSQL Connection .NET Helper Library
I recently posted my old .NET MSSQL Wrapper to be code reviewed: .NET MSSQL Wrapper
I had some good feedback and based on that, I was able to re-factor it quite a bit and ended up with the following ...
3
votes
1answer
121 views
.NET MSSQL Wrapper
Back in late 2012, I wrote the following C# .NET MSSQL Wrapper, which offered the following operations:
ExecuteScalar (for selecting single field from a row)
...
2
votes
1answer
51 views
T-SQL Constant Time Comparison
Explanation is in the function. Please point out any egregious errors:
...
1
vote
0answers
13 views
T-SQL Totp (Rfc6238 SHA2_256) Implementation
Using my previous function as a base I've come up the following:
...
3
votes
1answer
43 views
Returning two dates based on input
I created a function that will return 2 dates that depend on an input parameter.
When the parameter is:
1 - return start date of current week and end date of current week
2 - return start date of ...
4
votes
2answers
44 views
Basic Bill of Materials schema
I've been working on Bill of Materials mini schema for a while. At first I had single Part table where I've referenced itself. I was told it would be better to have ...
16
votes
2answers
1k views
Searching for bad Minecraft questions on Gaming.SE
To preface this post a little bit, I'll explain a little bit of the "backstory" here. The Stack Exchange site, Gaming.SE, also known as Arqade, often has a large influx of bad questions about the ...
1
vote
1answer
38 views
Managing employee photos in a database
I'm looking for a better way to manage employee photos for employee records in our database, and a way to query for the employee photos while having them on disk I have used a ...
3
votes
0answers
36 views
T-SQL Pbdfk2 (Rfc2898 SHA2_256) Implementation
Using my previous function as a base I've come up the following:
...
1
vote
3answers
131 views
Checking user access to servers
I have pasted a method I wrote, which is too slow to my liking (easily takes 60+ seconds to execute). The method loops through 12 different servers, checks if userX has access to any of the databases ...
4
votes
0answers
78 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:
...
2
votes
1answer
26 views
2
votes
1answer
28 views
Find foreign key membership including owner in SQL Server
Was hoping someone could sanity-check this SQL statement. I need to find the owner (schema), table, and column on both sides of a foreign key:
...
1
vote
1answer
34 views
Acquiring the number of contracts for persons
This script shows the number of contracts for persons. Table Contract has more than 82008 records and Candidate has about 7978.
...
4
votes
1answer
92 views
SQL Permission Handling in WinForms
For my application, I've opted to use Integrated Security with Windows Authentication to access the SQL database. I've created AD security groups for each role and given them ...
2
votes
2answers
42 views
5
votes
0answers
24 views
Finding closest points without duplicates and given distance threshold
Given a bunch of latitudes and longitudes stored as Points, I would like to determine the points that are closest to each point given some maximum threshold in meters. This is my first stab at this:
...
1
vote
0answers
33 views
SQL Query Count Records and Pull Distinct
So I need a little help. It is currently working but I might have over complicated it. So maybe someone has a better idea. Now let me try and explain it.
I am trying this query, and it currently ...
1
vote
1answer
42 views
Query performance of this Select Where each Column is a Select
I would like to know how to improve the performance of the following query:
...
1
vote
0answers
86 views
Updating datetime fields from UTC to local time zone
I have created an SQL query to update datetime fields from UTC to local time zone. Can someone review this?
...
2
votes
0answers
29 views
Annualized Turnover Report
What can be made better? How ugly is my code? If it's terrible, where can I improve?
...
0
votes
2answers
122 views
Optimizing LINQ routines
I run a build system. Datawise the simplified description would be that I have Configurations and each config has 0..n Builds.
Now builds produce artifacts and some of these are stored on server. ...
3
votes
3answers
153 views
Find a Id that contains all mentioned values
I have a scenario to find the CategoryId which all have the mentioned Mode values.
The schema of the table ...
13
votes
2answers
115 views
Sales, Taxes and Totals
I'm working to get some practice with SQL functions which are often used in a financial setting, and I created this simple table with products, prices and tax rates basically.
I then wrote a query to ...
2
votes
1answer
48 views
Simple DB API for inserting a record
I'm looking to make some improvements to a deliberately crude API written in PHP, it's designed to handle simple requests and talk to the DB.
I have the following DB class:
...
4
votes
0answers
24 views
Tag wikis under a certain length
I wrote a SEDE query to list all tag wikis with a body or an excerpt under a given number of characters. I've used this to find empty wikis or wikis with very little information. The tags can be ...
5
votes
1answer
52 views
Searching posts/comments by keywords
I've put together another simple query that allows you to search post/comments with specific keywords. At the moment, only post bodies are checked.
...
0
votes
2answers
76 views
Creating multiple objects from SQL server extract
I've created a simplified prototype solution as a sort of proof of concept before starting a larger program.
Here is the test data used to build the objects:
...
0
votes
1answer
53 views
Merge inserted and deleted tables in SQL trigger
I have a table with a Balance column of type decimal(18,0).
I want to get updates to its ...
2
votes
2answers
59 views
Custom SQL statement
I am just wondering if my code can still be simplified. I intend to make it reusable in all update statements.
...
9
votes
3answers
387 views
Popular questions by view count
I made this query to create a graph of a user's popular questions and the view count on that question. It allows for a minimum of 500 views, and a score of ...
5
votes
0answers
53 views
Finding which users have the most questions with unaccepted answers
I was looking at a few profiles this afternoon and noticed a few users had plenty of open questions. This led me to wonder which users actually had the highest amount of questions with unaccepted ...
3
votes
2answers
35 views
Percentage of questions that are unanswered or answered - Part 2
I've refactored my previous query and added better checks when selecting the data. The query link can be found here. The formulas used to calculate the two percentages are the same, and can be seen ...
3
votes
2answers
47 views
Trigger that updates counter
I've got the following schema, which can not be modified since it's a problem taken from an exam:
...