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
votes
0answers
9 views

Best Way to Create Table of Aggregate Values SQL [on hold]

Short question: Is there a simple way to get tables of aggregate values to display in neat rows and columns in raw sql? Ex. Total sales over select years, where the column names are the years and ...
0
votes
0answers
28 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. ...
2
votes
2answers
50 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 ...
11
votes
2answers
54 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
41 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
22 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
46 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
54 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
20 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
52 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. ...
8
votes
3answers
381 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
37 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
34 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
17 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
50 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
290 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
0answers
32 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
36 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
30 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
98 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
38 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
129 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
46 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
127 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 ...
16
votes
2answers
251 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
44 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
53 views

Using Stored Procedures in ColdFusion / Lucee

This is how I write all my database interactions now in Lucee: ...
11
votes
1answer
277 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
273 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
209 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
93 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
18 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 ...
1
vote
0answers
32 views

Creating a wrapper for SqlClient

I'm trying to find out what is the best way to create a class so I can use it to connect to the SQL Server and be able to rollback everything if a single error exists. Right now, I'm using a single ...
1
vote
1answer
52 views

Stored procedure where column to ORDER BY depends on input parameters

I'm getting three inputs and based on those three inputs, I'm returning. Input items may vary, so I used CASE WHEN statements here. Is this code correct? If so, ...
3
votes
2answers
44 views

Updating user log in time while he logs in to the web page

My intention is to store the user's last login date and time when he logs in to the web page. I pass his username and password to the stored procedure to check whether is it correct or not! I believe ...
4
votes
1answer
36 views

Checking that data has been created in multiple tables

I have 4 tables that I want to check for data. When there are Rows in all the tables, I want to print a message for success. When there aren't any rows in any table I print an error (when 1 or more ...
5
votes
2answers
51 views

1st questions with answers within X hours

I recently challenged @Hosch520 with writing a query as such: Find first questions with answers posted within 24 hours And he did great. I figured I would have a go at it too. Turns out I ...
3
votes
1answer
50 views

Perform SELECT INTO Statement and add Primary Key afterwards

How can I imrpove the performance of this T-SQL statement? ...
3
votes
1answer
199 views

Classes for reading data from Sql Server into objects

The following is a set of classes that read metadata from Sql Server tables and populates local objects. It works, but I feel like there's too much duplication happening and too many places changes ...
8
votes
1answer
54 views

Assigning permissions to new role without RBAR

I'm currently faced with a problem in our SQL Server environments. We need to migrate our existing logins, users and roles to a new login, user and role with the same permissions as the old. I've been ...
6
votes
1answer
47 views

Searching school data

I am running a test load using Telerik Test Studio using 100 users at once entering search filters on a page that calls a stored procedure. My application that calls the stored procedure is an ...
3
votes
2answers
35 views

SQL server efficiency, comparing date time of latest record and the one under it

I have a snippet of SQL that compares the last two records and gives the datediff in seconds. However, the way I have it is quite slow, taking up to 20 seconds to execute depending on how many ...
-4
votes
3answers
133 views

Application search form

I have a search form in my application. When I search, it takes too much time to retrieve and display data, so I need to optimize this code. ...
2
votes
2answers
93 views

SQL Server to MongoDB Template

Looking for feedback on a set of templates I've just created. I'm planning on converting them to Yeoman but want to make sure they're ready for prime time before doing so. They are currently in ...
5
votes
0answers
60 views

Split string in chunks preferable at spaces

I'm working on a tool to import data from one database to another. One requirement is that I have to split a string from one source field into three (shorter) fields at the target. If possible the ...
4
votes
1answer
78 views

Luhn algorithm MS-SQL

This a solution Luhn algorithm for credit validation. This algorithm is a basic one inspired by wikipedia. I mean no check for length, type, and so on. You can enhance the base code as you want it to ...
5
votes
3answers
246 views

SQL database design for ecommerce

I need to create a database which stores details products, Manufactures,Suppliers. So initially I divided Products into categories and subcategories. These are the tables I created. ...
7
votes
1answer
46 views

Stack Exchange Data Explorer query to find upvoted questions with only downvoted answers

I have written a SQL query against the Stack Exchange Data Explorer that identifies answered questions with a positive score for which all the answers have a negative score (this was an answer to this ...
2
votes
1answer
41 views

Select Queries From Parent-Child Tables Model

I have two tables (parent-child model): Loans & Transactions. Each Loan row has multiple Transaction rows. I want to select all rows from Loans together with most recent row from Transactions. ...