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

learn more… | top users | synonyms (1)

1
vote
0answers
5 views

T-SQL Totp (Rfc6238 SHA2_256) Implementation

Using my previous function as a base I've come up the following: ...
3
votes
1answer
29 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
38 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 ...
15
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
26 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
33 views

T-SQL Pbdfk2 (Rfc2898 SHA2_256) Implementation

Using my previous function as a base I've come up the following: ...
1
vote
3answers
122 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
63 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
18 views

MSSQL query with join and where clause

I've the following tables ...
1
vote
1answer
21 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
33 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
65 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
39 views

SQL query to select most recent version

I have the following table definition: ...
5
votes
0answers
20 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
28 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
40 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
64 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
25 views

Annualized Turnover Report

What can be made better? How ugly is my code? If it's terrible, where can I improve? ...
0
votes
0answers
70 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
105 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
86 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
45 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
23 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
50 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
64 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
0answers
38 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
58 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
385 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 ...
4
votes
0answers
43 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 ...
2
votes
0answers
21 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: ...
2
votes
2answers
59 views

Job execution on records supplied by database

I have a requirement to check all records in a table which is big (Around 1.5-2 million records). What I am doing is very simple, just get all the records and loop through one by one, and do things. I ...
10
votes
2answers
298 views

Percentage of questions that are unanswered or answered

I put together this simple query which calculates the total percentage of answered questions and unanswered questions. The formulas used to calculate these are shown below: $$ \text{Answered ...
1
vote
1answer
44 views

Get Next and Previous “Load Day”

I keep looking at this trying to figure if there's a better way. All three functions work, but I wanted to get some insights and ideas from others. IsLoadDay ...
2
votes
1answer
55 views

SQL Nested Selects

I was wondering if there is a better way to do the nested selects so that the firstname and surname is only doing one select ...
2
votes
1answer
37 views

Pull data from database to generate XML files

I have the following script in Perl that does the following: Prompts user for time in epoch. If user enters '########', the query will look for all reports generated after that date/time. If user ...
5
votes
2answers
184 views

SQL procedure with cursor to check if values in table 1 are also in table 2

The problem is that I'm checking if result from cursor exists in CDN.ZamNag table for every iteration. Is there any better way to check if values in table 1 are ...
0
votes
1answer
78 views

Synchronizing two SQL Server database tables with the most recent changes to both tables

I'm very new to SQL, but I'm coding a C# program that interacts with a database. There's a master database on my computer, and there's a client database on my tablet. When I re-connect my tablet to ...
5
votes
2answers
131 views

Finding questions to answer - Part 2

I've refactored my previous question finder, and added multi-tag support, and support for searching for keywords in the question titles. Essentially, what it does is find questions that could be ...
2
votes
1answer
55 views

Backing up two tables using SQL transactions

I'm using a transaction statement in SQL Server 2012 for the first time. I want to insert Table1's data in Table1_Backup before ...
8
votes
2answers
133 views

Finding questions to answer

In light of the recent "SQL frenzy" of sorts in The 2nd Monitor, I decided to take a stab at writing my own SEDE query. Essentially, what it does is find questions that could be answered based on the ...
17
votes
2answers
273 views

“How can I make this SEDE query better?” (bad title finder)

It was suggested on Meta for July 2015 Community Challenge to make a bot that can find questions with bad titles. I wrote this query to help others find examples to help them make write their code. ...
18
votes
4answers
2k views

Top users under age 30, sorted by age, with rank

In the pursuit of SQL enlightenment, I wrote a quick SEDE query to display Rep, Age and Overall ...
8
votes
1answer
58 views

The opposite of CodeLess Questions query

What's the opposite of CodeLess Questions? Perhaps CodeOnly Answers? (Also known as code dumps.) Inspired by the opposite question, here's the opposite query: ...
0
votes
1answer
61 views

Using Stored Procedures in ColdFusion / Lucee

This is how I write all my database interactions now in Lucee: ...
11
votes
1answer
289 views

CodeLess Questions query

As part of an exercise by Jamal to clean up old questions on Code Review that have no code in them, I helped by writing this query on Stack Exchange Data Explorer: CodeLess Questions ...
4
votes
2answers
342 views

Database Update class using SQLCommand

I would like to have advice on this use of base class and derived class. This all works but is it a good way to achieve a SOLID class? ...
3
votes
2answers
258 views

Creating Sequential IDs

I'm using SQL Server 2014 with Visual Studio 2013. When I add a new record, identity column (seed 1, increment 1) "ID" increases by 1, and record added to the database. My table consist of two rows: ...
3
votes
0answers
150 views

Generic SQL Connector classes

The need came up the other day to be able to easily switch back and forth between making IBM DB2 queries and MS SQL queries. I didn't want to mess with NHibernate ...
0
votes
0answers
22 views

Create variable and use in one stored procedure

This finds a value via a stored procedure then runs a second process in the same stored procedure rather than calling a second stored procedure. When a call is 'simple' i.e. not Where x y then... I ...