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)

0
votes
0answers
10 views

Techniques to optimize this stored proc to generate a sales report?

I need to optimize the following stored proc. Please let me know of any techniques or modifications that I can make to optimize this piece of code. The procedure is for a report that needs to run ...
5
votes
2answers
51 views

DateTime internal representation to FILETIME

Here is a routine I put together to convert SQL Server's internal DateTime representation (BINARY(8)) to a ...
-2
votes
0answers
30 views

c# difference between two dates [on hold]

in my GridView i have a method call DisplayWarning() and I want to calculate the day difference between date column( in my SQL server ) and ...
1
vote
1answer
25 views

Too many parentheses to format a percentage in SELECT

This query seems to have way too many parentheses. ...
3
votes
1answer
37 views

Monthly change query with SQL Server 2012

I'm new to SQL and working on a monthly change calculation. I want to calculate the change between this months balance and the previous months balance. This query is working for me but does not ...
3
votes
2answers
97 views

Similar statements need duplication removed

How would you refactor this? ExpensiveQuery must only run when necessary. ...
4
votes
1answer
66 views

Unduplicated counts over various dimensions

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

Get and display employee time clock data

I have been making a web page in PHP and JavaScript to take employees clock times and do some things with them so I can display them. Everything is currently working quite well, but the code looks ...
6
votes
5answers
341 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
188 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
114 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
76 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
25 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
2answers
208 views

SQL percentage calculation

I have created a query in which there is a column that calculates a percentage: ...
4
votes
1answer
78 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
117 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? ...
17
votes
1answer
191 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
84 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
77 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
315 views

FizzBuzz in SQL--no loops

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

Sorting three Decimal values

I have been given three values. @lLength, @lWidth, @lHeight. I need to take these ...
10
votes
1answer
69 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
62 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
309 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
247 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
170 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
70 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
94 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
179 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
93 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
65 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
112 views

Count and group rows for six months prior

I've written the following query for SQL server: ...
7
votes
2answers
659 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
198 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
485 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
77 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
259 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
50 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 ...