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 (2)

1
vote
2answers
88 views

Query to return zero if nothing exist

I have a table With currency, paymenttype and invoiceamount. I have to write a query to get currency, paymenttype and total invoiceamount made. This is pretty simple with group by. But actually I ...
0
votes
1answer
38 views

SQL Server Express Limitation

I would like to use Express instead of Standard. Does Express still have the annoying habit of going to sleep if left unused for a period of time?
1
vote
1answer
47 views

Using LIKE or Full-text when searching database

I am fairly new to SQL and I am currently trying to create a search function for my website, much like the one on imdb.com. I have 3 tables and I need to search two rows (nvarchar) in each table when ...
1
vote
2answers
44 views

Stored procedure big where clause or multiple procedures

Is it better to have one big query or N small ones? For example to select all the customers with multiple parameters: select id, name, firstname, city, birthday, ... from ...
0
votes
0answers
48 views

TSQL LAG equivalent

I am trying to understand how lag works, by converting the following code back to using self-join sql code without using lag. https://msdn.microsoft.com/en-us/library/hh231256.aspx USE ...
1
vote
0answers
18 views

SQL Server Transactional Replication

I am using SQL Server 2012 and I am investigating transactional replication and had a question on SQL Versions that can be used. The Distribution and Publisher will be on SQL2012 Standard Edition, ...
7
votes
1answer
124 views

Unable to restore (error 3456)

I have a situation that is not easy to figure out, and thought I'd ask on this forum if others might have suggestions. I'm running SQL Server 2008 R2 Standard SP3 on Windows Server 2008R2 Enterprise. ...
1
vote
1answer
59 views

SQL Server 2012 - Dropping Snapshots takes hours

We recently did a SQL Server upgrade from 2005 to 2012. We have a nightly job that drops a snapshot of an active database. The snapshots gets created again later in the day. Before upgrading, in SQL ...
2
votes
1answer
29 views

Replicating to Older Versions of MS SQL Server

According to an old MSDN article (from the SQL Server 2008 R2 era), Microsoft SQL Server transactional replication subscribers need to be within two versions of the publisher. Does this hold true for ...
2
votes
0answers
56 views

How to copy SQL Server log shipping files to AWS EC2 instance

I am using SQL Server 2008 R2 and would like to log ship from my local data center SQL Server instance to a log shipping target SQL Server running in AWS EC2. What is the best way to copy the log ...
1
vote
0answers
28 views

Changing filegroups from primary to user-defined for existing table in SQL Server

I have 10 million records in a table. But the table is created on primary filegroup.All the indexes and primary keys were created in primary filegroup.There 5 partitions on the table which are also on ...
0
votes
0answers
10 views

Changing filegroups from primary to user-defined for existing table in SQL Server

I have 10 million records in a table. But the table is created on primary filegroup.All the indexes and primary keys were created in primary filegroup. Is there any way to move Table, indexes and ...
4
votes
1answer
184 views

Order In WHERE Clause Matter For SARGability?

Suppose that I have a table with 1000 records and I have the below query, which would return 7 total records: SELECT * FROM MyTable WHERE IndexedColumn > 5000 AND OtherIndexedColumn = 2 ...
-4
votes
1answer
18 views

ExecuteNonQuery () not fungsional and database failed [closed]

Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim SumberDb As String = "Data Source=c:\users\ogieuntung\documents\visual studio ...
0
votes
2answers
42 views

SQL Server choose at random from giving data

My problem is that I don't know how to choose the random data from a giving set. For example: I have a Node column which need to produce different inserts but only from these numbers: 16, 17, 18, 22, ...
0
votes
1answer
42 views

Different runtimes using parameter vs. constant

A strange thing is happening to me during execution a specific query. I have this query: DECLARE @P0 as varchar(4000) DECLARE @P1 as varchar(4000) SET @P0 ='P0' SET @P1 ='2015-02-21 00:00:00' ...
1
vote
0answers
52 views

How does SQL Server know it was abnormally shutdown last time [closed]

I am doing background reading on this. Would like to know how does SQL Server know it was abnormally shutdown last time?
-2
votes
0answers
24 views

Enable sql row versioning and issue in select inserted row

I worked on a project that high rate of insert and select execute on it. after a while I saw below error: was deadlocked on lock resources with another process and has been chosen as the ...
0
votes
0answers
34 views

Partitioning large table requires lots of extra disk space: does switching recovery model help?

We are in the process of implementing partitioning on a SQL Server 2012 database. It worked fine in our environment, but in the client environment we ran out of disk space. The entire database was ...
-2
votes
1answer
71 views

Arithmetic overflow error for type varchar

This is my query: insert into [Consolidated_LoB].[dbo].[consold] ([shp_to_pstl_cd] ,[LoB] ,[catlg_nbr] ,[shpd_qty]) select [POSTAL_CODE] ,[LoB] ,[PART] ...
-1
votes
1answer
65 views

SQL Server's aggregate functions ignore nulls. How do I correct this?

According to MS's knowledgebase, Except for COUNT, aggregate functions ignore null values. Does anyone know how I can get it to work correctly, that is, return a null if it attempts to ...
0
votes
1answer
58 views

Single query approach to split and copy string values in a column

This is a part of my previous question. I have the below logic to split a string value from a column in table tblProjects as below: SELECT @Docs = Documents FROM tblProjects WHERE ID = @ID SET ...
2
votes
1answer
102 views

T-SQL CTE Compare previous non-NULL and current row to filter out by difference value

My sample database (in fact a CTE statement data) looks like this: eventdate val 2012-03-23 3965 2012-03-26 3979 2012-03-27 3974 2012-03-28 3965 2012-03-29 3967 2012-03-30 3959 2012-04-02 ...
-2
votes
1answer
47 views

What are the ways to handle temp table with more than 9000 rows? [closed]

I am creating a temp table in my stored procedure which has more than 9000 rows and I read some articles saying that its bad practice to use temp table with more than 9000 rows as it uses temb db for ...
0
votes
0answers
24 views

how to create an online Database that tracks members only 1 level deep for each member

I want to create a database for a web site so that when a member signs up they have the option of choosing their sponsor (the person who referred them). Each member only has to sponsor 2 other ...
0
votes
1answer
38 views

Is it possible to install SQL Server 2014 Enterprise on Windows 7?

I'm planning to install SQL Server 2014 Enterprise Edition on a 64bit HP workstation. I read the SW and HW requirements on: https://msdn.microsoft.com/en-us/library/ms143506.aspx And according to it, ...
3
votes
1answer
92 views

Biggest wait WriteLog

I have been given a server (SQL Server 2008R2 64 bit) where our application is running. There has been a gradual decrease in the performance of the application. Now it has come to a point where ...
3
votes
1answer
102 views

Are we required to handle Transaction in C# Code as well as in Store procedure

Do we really require transaction handling in c# as well database store process both side C# Using(transaction with transaction scope) { Execute store proc; Transaction. Complete; } SQL ...
1
vote
2answers
55 views

SQL Server 2012: set a column to only use a single case?

Is there a way to tell SQL Server 2012 to store both A and a as A (or both A and a as a) for some given column such that every insert statement does not need to have UPPER() in it?
6
votes
1answer
277 views

Can SQL Server's Page Life Expectancy be too high?

I've read several articles about SQL Server's Page Life Expectancy and what it means and what kind of information you can glean from it. In most of these articles that I've read, a common, healthy PLE ...
0
votes
1answer
43 views

Normalising Customers and Employers with a people table

At what normalisation stage is it recommend to split say Customers and Employees into a people table and then link to the unique attributes of Customers and Employees. I cant seem to find the ...
0
votes
0answers
43 views

SQL Server 2014 Management Studio cannot design table

I am attempting to design a table via the right click menu on the table After I choose design I immediately get this error Object reference not set to an instance of an object (SQLEditors) ...
2
votes
1answer
42 views

How to efficiently create a new PRIMARY KEY CLUSTERED definition online

Given a table with a PRIMARY KEY definition (acting as the clustered index), I want to efficiently change the definition of the PRIMARY KEY (or at a minimum, just the clustered index) online. I would ...
0
votes
0answers
42 views

Shrink Database/Log (growing and non growing)

Before you yell and scream do not shrink at all. I have read every article that says why you shouldn't but I could not pinpoint the info I was looking for to help me understand my situation. Here is ...
1
vote
0answers
21 views

Converting existing table with varbinary into filestream enabled table?

I have an existing database with 70%+ data in one table with a varbinary column. As the database keep growing (takes longer and longer to backup and restore) I think it may be beneficial to enable ...
2
votes
1answer
45 views

Tool for quickly backup and restore a table

Is there a tool for quickly backup and restore a table's data, preferably to a csv file? It would be best if I could do it using batch. Run a .cmd file and data is backed up into a file with datetime ...
1
vote
1answer
32 views

System.Data.Entity.Infrastructure.CommitFailedException: C# Multithreading & SQL Server 2012

We have a C# multi threaded (100 threads) program which reads the records from the DB and each thread picks up one record (one Entity Framework connection per thread) and update the a single DB table. ...
0
votes
0answers
27 views

How to Make a Condition Before insert a Row According to XML value

I'm facing a logically issue in SQL SERVER 2014 that how can i make a condition to insert a rows , these rows must be a valid values and these values are included in Xml Column I've Two (2) Tables ...
1
vote
1answer
13 views

Geographically dispersed SQL Server for Third Party Application [closed]

I am kind of new here but I hear that this is the place to come if you have a difficult question. We currently manage an Third Party Application for a customer that has expanded from it's UK base ...
1
vote
3answers
169 views

How to create a SQL trigger to execute a stored procedure when a table is updated

i need some help with creating a trigger to run a qf.stored_procedure when a qf.table is created. AT the moment, i have a job t run the stored procedure every 15 minutes but changing that is not an ...
2
votes
1answer
32 views

Does DBCC TRACEON() invalidate cached execution plans?

In Microsoft SQL Server, does DBCC TRACEON() invalidate cached execution plans, same as SP_Configure invalidates all stored procedure plans ?
0
votes
0answers
37 views

Database Hangs while trying to run sql

I have a challenge with SQL Server. We are running SQL with an inhouse developed application. Lately we have been having a challenge where the DB hangs and users are unable to access the application. ...
1
vote
1answer
49 views

What causes 'Recovery completed for database …' log messages?

I am running an MS SQL Server Express (64-bit v11.0.2100.60) database and now and then I get problems that my connections times out when I want to connect. In the server log I can see that at that ...
1
vote
1answer
49 views

Some data is missing in the table of SQL

I have given a description column datatype as NVARCHAR(MAX) but when I add the data it shows me only half data. Not full data. For Example:- If I have two para like below:- As the saying goes ...
1
vote
0answers
28 views

Restore Database w Master Key and storing password in plain text

We have a (SQL Agent)job that backs up our production db nightly(and restores to a test db server) and we're adding encryption to some of the columns in our tables. I created a master key and bound ...
1
vote
2answers
38 views

Understanding deadlock XML

Recently a clients website has been receiving many deadlocks. The website and CMS is custom built on asp.net MVC 3. The database is SQL Server 2008. I believe this started occurring when there was ...
0
votes
1answer
67 views

What is the correct SQL for using where ID in List and the items are with AND operator

I need a SQL Statement to use IN operator within the items with "And" connected. SELECT * from tbl_Users WHERE id in [1,2,3] is equivalent to: SELECT * from tbl_Users WHERE (id=1) or (id = 2) or ...
6
votes
1answer
131 views

SQL server service won’t start after disabling TLS 1.0 and SSL 3.0

Because of security reasons, we disabled TLS 1.0 and older protocols on our windows, and enabled just TLS 1.1 and TLS 1.2 under the following registry path: ...
2
votes
3answers
290 views

How to speed up a multiple select query

EDIT - Putting my whole stored procedure: I have the below stored procedure: CREATE PROCEDURE [dbo].[data_Update] @Owner NVARCHAR(255), @ID VARCHAR(255), @Division VARCHAR(255), @Manager ...
2
votes
1answer
231 views

Why does SUM() return 0 when no rows in table?

I've been saying for years that if you are assigning an aggregate value to a variable that you need to handle if there are no rows returned. ie: DECLARE @MyVar INT SELECT @MyVar = SUM(t.MyValue) ...