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)

4
votes
1answer
62 views

Unduplicated counts over various dimensions

I'm working with some data on college students, which has a unique key of SSN, Campus, ...
6
votes
5answers
332 views

Transaction handling for multiple SQL statements

In this code I update two tables called Payment and SalaryTrans. First I insert records (Salary payments) to ...
5
votes
3answers
187 views

Legacy Data and Current System Data Merged together in a single SQL Database

There was a lot going on in this Database that I couldn't change, a lot of bad practices because the data was originally being pulled from an old mainframe database and then transformed by a horrible ...
3
votes
2answers
109 views

Efficient way to extract the first row in a Group By group

I have a large Sql Server view with this schema: [archive_ID] (int, not null) [archive_date] (datetime, not null) [archdata_path_ID] (varchar(50), not null) [archdata_value] (int not null) I need ...
5
votes
3answers
72 views

Relational schema and query for multiplayer tabletop game

As an exercise, I was asked to design a database schema (for MS SQL Server) for a tabletop game. The requirements were simple: players compete in matches and there are specific match types (e.g. 1v1 ...
2
votes
1answer
32 views

Reusing select statement

I am checking if there are any rows in a table with some conditions. If there are more than 1 row, it should filter again with some more conditions. ...
3
votes
1answer
24 views

Optimize mass import of XML to SQLServer in Ruby

I have the following Ruby code that's designed to update item, price and stock data for items in a MSSQL database. It's running on a Ruby 1.8.6/Rails 1.2.3 installation, in its own controller (for ...
4
votes
3answers
204 views

SQL percentage calculation

I have created a query in which there is a column that calculates a percentage: ...
4
votes
1answer
76 views

Batch of SQL statements in a single query

I'm using the following query for multiple transactions. This is the scenario. Generate Salary (this is not in the scope of the query) I have employee attendance in ...
6
votes
2answers
262 views

Multiple SQL statements in a single transaction

Using the following query I'm doing transactions with two tables ...
4
votes
2answers
113 views

Delete from multiple tables using temp table variable

I'm previewing the data I'm about to delete, but this SQL looks a little redundant. Is there a better way to write this? ...
14
votes
0answers
152 views

Executing large SQL script file with GO statements using ADO

I wrote a small component (still in the works but working) which takes a large SQL script file, splits it into different "blocks" based on GO statements, and executes them one by one. The only major ...
2
votes
1answer
77 views

Is there better way to shorten this Lambda expression's result selector?

I'm new in LINQ and Lambda expression. I'm not sure is there a way to shorten the result on this o.z.cust.cust.cust.bintAccountNo. As you can see below, the more ...
6
votes
3answers
73 views

SQL Stored Procedure Get Distinct and Update

The idea is to show how many times a user (by EmployeeID) is in the TblTableList and then update the ...
12
votes
2answers
312 views

FizzBuzz in SQL--no loops

MS SQL Server, no loops. ;) ...
6
votes
3answers
102 views

Sorting three Decimal values

I have been given three values. @lLength, @lWidth, @lHeight. I need to take these ...
9
votes
1answer
68 views

Loading Data Warehouse with Dynamic SQL

For a data warehousing project I ran into the following: Custom fields that users can create, modify and delete, that should be loaded into the data warehouse as they are when the ETL happens. On ...
3
votes
1answer
37 views

Printing simple SQL comparsion

I'm comparing two variables which I'd like to be printed to the console like so: ==Full Ex Vat== true Currently the code to do this is: ...
2
votes
2answers
39 views

Using Common Table Expression and Outer queries

In following query I'm use both Common Table Expression and Outer queries. Apparently both looks same to me. If I summarize my requirement, I have employees in ...
5
votes
2answers
61 views

Better way of calculating a time in a time zone from multiple dates in SQL?

I'm trying to calculate what time a certain time in a time zone is today, so I can schedule something to happen at that time in that time zone. I've got a table with what I have termed the Nominal ...
10
votes
3answers
306 views

Is there any way to speed up this stored procedure?

Is there any way to optimize this stored procedure? Maybe something instead of so many joins? It takes some time to execute. Maybe there are other options that I could look into? ...
5
votes
1answer
58 views

EF query for calculating monthly trends

My application has a fairly important query that is used in a lot of places. Unfortunately it takes about 14 seconds to run, so I'd like to find a way of possibly improving it. The application ...
11
votes
2answers
240 views

Find records with duplicate serial number

I was tasked today with cleaning up data from a SSRS report put together by a DB programmer. The original report was to find duplicate serial number sales within a user-defined period of time. I was ...
7
votes
1answer
150 views

Fluent Nhibernate, is the mapping correct?

I'm very new to NHibernate and DB. I have three tables which are connected with many to many relationship. Here are the tables creation Script: ...
3
votes
1answer
63 views

Insert an SQL Server Table rows into a Bigquery table in one bloc

I want to insert all rows of an SQL server Table into a Bigquery Table having the same schema. The streaming insert row by row is very slow: to insert 1000 rows ...
2
votes
2answers
90 views

Simple Data Access Layer

I have DatabaseContext class. ...
5
votes
1answer
465 views

Can I populate this table faster?

I have the following SQL query which takes ~3 seconds to run, maybe ~4. This populates a consultants table with their expected payments for the month. Unfortunately, the page only loads when this ...
2
votes
1answer
166 views

Stored Procedure calculating employee earnings

I have following stored procedure in a C# win forms application which calculates employee earnings based on attendance as follows. Note that a shift is 12 hours and employees mark attendance for in ...
1
vote
0answers
85 views

Insert all SQL Server table rows in a Google BigQuery Table

I am coding in Coldfusion. 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 ...
1
vote
2answers
63 views

Text file searching using SQL

I have the need to search a directory containing 1000+ files on remote servers where I only have access to SQL Server Management Studio and Explorer. I have written the below SQL statement which does ...
6
votes
1answer
110 views

Count and group rows for six months prior

I've written the following query for SQL server: ...
7
votes
2answers
576 views

VB.Net Database Access Class

I've recently been asked to make some emergency changes to a legacy application written in VB.Net. I come from a C# background so am not overly familiar with this language, though there are enough ...
4
votes
1answer
44 views

SEDE query to find users with exactly one post in a particular tag

I'm doing some research for a meta post on Gardening.SE (where I'm a pro tempore moderator). I'm using the Stack Exchange Data Explorer (SEDE) to find information about first time users who post ...
3
votes
2answers
48 views

Calculating percentage of 3 test forms

Please help me to simplify the script below. It has a lot of variables and a lot of values are getting assigned to them. Can I make it simpler? It has to calculate the percentage of 3 test forms: ...
10
votes
1answer
189 views

Password Manager UI: Populating DataGridView is Painfully Slow

I'm designing a small account/password manager using C# and SQL Server CE. LINQ to SQL is my ORM of choice. Here's the data model representing how the SQL Server CE database is set up: And here's ...
7
votes
2answers
435 views

Creating ADODB Parameters on the fly

I have put together a small wrapper class to simplify creating parameterized ADODB queries with VB6/VBA. At this point I'm keeping things simple, so it's only supporting input parameters and from what ...
2
votes
1answer
45 views

The use of database “sets” rather than “functions”

I've currently got a MSSQL stored procedure that uses multiple SQL functions to achieve a number of returns. Now I've been told about using sets rather than functions as it creates " bad code smell of ...
5
votes
2answers
70 views

Update column based on input variable in stored procedure

The purpose of the below code is to update a column based on the name of the field name sent from the .NET code. This allows one piece of code to handle multiple rows when a user is only ...
0
votes
1answer
62 views

How can I modify this query for performance?

This is the stored procedure I'm using to list some places in my website. How can I optimize it to perform well? Which functions in query is taking much time for its execution? ...
6
votes
2answers
91 views

Inefficient query actually more efficient?

I have two queries; one runs significantly faster than the other, but the faster one is the one that I would have bet money on to be less efficient. These are both being executed through a front end ...
10
votes
2answers
245 views

Another way to run reports on a SpiceWorks SQLite database using a linked server in SSMS?

I created a linked server in SSMS so that I could run reports on a SpiceWorks SQLite database. there are a few quirks in the whole system. These simple queries are becoming some of the most ...
6
votes
1answer
48 views

Aggregating Conditional Sums

I have recently forked/rewritten a SEDE query (here) that aims at figuring out where a site stands in terms of avid users and distribution of reputation scores, compared to a specific target (number ...
5
votes
1answer
352 views

Fastest image upload into SQL database

Hello I am trying to upload an image (screenshot from desktop) to SQL database as fast as possible. I would like to optimize my current procedure in terms of speed: ...
3
votes
1answer
376 views

Populate Drop Down List from SQL Database

I am populating a drop down list from my SQL database. List should be able to be displayed with active only, inactive only or both at the same time. OfficeRepository.cs: ...
5
votes
2answers
176 views

Do I have any SQL leaks?

This is a Windows service that will run on about 600 machines. It is used to track the job server that a user is connected to (pushed through some kind of load balancer, not my area). I store this ...
0
votes
1answer
26 views

What datatype should I use to complete this task [closed]

I want to be able to allow a user to not put the leading ZERO on any decimal number in a textbox in C# ( like .1 ). I then want to convert this to a decimal or float or any datatype that will ...
3
votes
1answer
44 views

Best way to get two columns from a table

Basically I have taken over a project and found a table that has the following video and video title fields in it (why they didn't create a separate linked table is beyond me): ...
8
votes
3answers
367 views
2
votes
2answers
112 views

Returns Office Details from Database

I am building an Administration web site for the Office details in my database. Right now, I am just trying to display the office details. ...