All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag like sql-server-2016 if that is relevant to the question.

learn more… | top users | synonyms (2)

2
votes
1answer
71 views

Missing .msi files gives error while repairing SQL Server 2008R2

I've got a SQL Server 2008R2 SP1 database installed and I'm trying to run a repair on it using a 2008R2 install binaries. In the middle of the repair loading, the window suddenly shuts down and gives ...
4
votes
1answer
94 views

Microsoft SQL Server 2016 performance degradation for stored procedure called 1000's of times

Context : Small table, stored procedure to update table, first two thousand hits no problem. After those first hits it starts to crawl to a snails pace. This stored procedure has no problems in our ...
1
vote
1answer
24 views

Documenting SSRS and SSIS jobs that are the Job Activity Monitor

We are running a SQL Server 2014 database using SSRS as a reporting tool. We have data coming in via SSIS jobs and linked servers. We have developers creating various SSRS jobs and scheduling them. ...
1
vote
0answers
60 views

The query processor ran out of stack space during query optimization. Please simplify the query

I'm using SQL Server 2014. When running this query: DELETE FROM shuser WHERE datecreated > '6/21/2016' AND FkShUserCreatedBy = 1 GO I get an error: Msg 8621, Level 17, State 1, Line 1 ...
1
vote
1answer
57 views

SQL Server TempDB size issue

SQL Server reported that our tempdb is out of space. So I had a quick google search and found this on technet https://technet.microsoft.com/en-us/library/ms176029(v=sql.105).aspx Determining the ...
1
vote
0answers
51 views

SQL Server x64 DBCC Shrinkfile Dies not release Unused space (never ends No errors) [duplicate]

I have a 1.8TB Production database in my test environment on a 2TB drive. Currently there is only 1 .MDF and 1 .LDF (on a separate drive). The Database has had some major cleanup of unused indexes, ...
1
vote
2answers
61 views

How to select sets of data from a table

I have a table containing data that represents a tree structure of data, using the nested set model. I'd like to store data for more than one tree in the table and have only one of the sets of data ...
1
vote
1answer
56 views

Aggregation using CASE

I have a table called country: CountryName | Sales A 200 B 100 C 300 D 500 E 400 Now I in my report I have hardcoded the parameter of ...
2
votes
2answers
47 views
+50

SQL Server Replication - Publication and Subscriber schema differ, need to sync

I have a SQL Server 2005 database where the publication and subscriber schema are different. This was intentionally done by turning the "Replicate Schema" option to False. However I now need to ...
7
votes
0answers
143 views

ROW_NUMBER() OVER (PARTITION BY B,A ORDER BY C) doesn't use index on (A,B,C)

Consider these two functions: ROW_NUMBER() OVER (PARTITION BY A,B ORDER BY C) ROW_NUMBER() OVER (PARTITION BY B,A ORDER BY C) As far as I understand, they produce exactly the same result. In other ...
1
vote
1answer
30 views

Create a Linked-Server from SQL Server 2008 R2 to AWS RDS SQL Server

How do I correctly create a linked-server entry, from an on-prem SQL Server, to an AWS RDS SQL Server instance? On-prem is 2008 R2, AWS-RDS is running 2012. This is the error I get when attempting ...
1
vote
0answers
41 views

SQL Server - can't import data-tier application from bacpac file (trying to move db + data from Server 2016 to 2014 SP1)

I'm trying to get a workable method to transfer a database schema and data from a SQL Server 2016 install to a SQL Server 2014 install on a different network. It looks like Import/Export Data-Tier ...
3
votes
2answers
73 views

Time based query help

I can't seem to get this to work the way I need it to. I have two tables Assignment and Event. Assignment StartDate EndDate Equipment 4/1/2016 4/23/2016 1001 4/3/2016 4/10/...
1
vote
1answer
34 views

Test connection for linked server fails on desktop but not on server [on hold]

On SQL Server 2012 I have a linked server to Oracle 12c. On the server a test connection succeeds. Security is set to be made using this security content with an Oracle user and no local logins are ...
1
vote
0answers
29 views

Installing SQL Server Express from SQL Server Developer Installer

If I install SQL Server 2012 Express using the SQL Server 2012 developer installer, do I still have access to all features available from the Advanced Services and/or With Tools versions of SQL Server ...
1
vote
0answers
27 views

SQL Server 2012 Performance issue while data load from Biz Talk Server

All of sudden BizTalk load has stated failing in SQL Server which was running for years without any issues. BizTalk will compile an insert SQL statement from flat file & insert data into SQL ...
0
votes
0answers
74 views

Query fast, but slow from procedure - or - why my new index is not being used? [closed]

In my wonderful job of tuning stored procedures, often times when I remove the query from inside the stored procedure it generates a very good plan, and when I put the same query wrapped inside a ...
1
vote
0answers
56 views

Fastest way to shred large xml data into a table

I have a nightly process that shreds XML data from a 17 million row table (120 GB) into another table, it takes about 3 hours and inserts about 1.5 million records. I currently do a complete drop ...
1
vote
0answers
27 views

SQL Replication Monitor does NOT show publication properties - Transactional Replication

The setup I have is as follows: a) Version SQL Server 2014 SP1 CU6. b) publication is on a separate availability group [AG1] and subscriber is part of another AG [AG2]. c) Distribution is ...
1
vote
0answers
59 views

Update statistics more often and stop defragmenting indexes

I have several vendor databases that have most (99%) of the tables clustered on GUIDs. Currently we are rebuilding the tables every weekend. Most tables are 80% or more fragmented by this time. ...
1
vote
1answer
42 views

How to give an existing server login access to an attached/migrated database

I'm migrating databases from SQL Server 2012 to 2014. I detached the databases from source server, then copied the files (.mdf, .ldf, etc.) to the new server and attached them. That process went fine, ...
1
vote
1answer
41 views

Time spent on the server vs network

Is there a way i can track for a given query how much time was spent by SQL server vs time spent in transferring data in network? I am learning performance tuning, hence this question. I am looking ...
1
vote
1answer
27 views

SQL backup to azure storage failed

I have a SQL Server 2014 up and running and I am trying to backup a specific database to Azure storage. I created a credential using the storage account name as identity and the primary key as ...
1
vote
2answers
62 views

Applying single quotes across multiple lines using ssms code snippet

further to Applying Quotes Across Multiple Lines Is it possible to create a "surround with" ssms code snippet to turn a list of values across multiple lines into an IN clause, so I could: select the ...
1
vote
1answer
36 views

Trim a value in an xml column in MS SQL Server

I have a database with an XML column. I am trying to update (trim) an xml value of the xml column. I am running on Windows, SQL Server 2008 Express. I did not find any way to trim directly in Xquery ...
1
vote
0answers
31 views

Report subscription deletion failed due to FK constraint

We have many SSRS report timed subscriptions (SQL Server 2008R2 SP4). One of our report developers tried to delete a report subscription, and got the following error: An error occurred within the ...
0
votes
1answer
33 views

convert historic local time to UTC taking into account of daylight saving

How should I convert historic local time to UTC taking into account of daylight saving? The main problem is the daylight saving doesn't occur at a fixed period every year and hence I cannot think of ...
3
votes
1answer
40 views

How would i create a report involving multiple many to many relationships

Lets say table A has a many to many relationship with table B, and table B has a many to many relationship with C. Two junction tables are created for AB and BC to form the many to many relationships. ...
1
vote
1answer
27 views

Connect SQL Server 2016 SSDT with TFS

I've just upgraded the SQL client tools on my PC to SQL Server 2016. I no longer have a "Team" menu option in SSDT. Under Tools > Options > Source control there is a drop down box for Source ...
1
vote
1answer
51 views

How Plan Explorer Group Operators in Query Columns Tab

The two Index Seek (highlighted in green and red) are for filtering, they did not group in Query Columns tab. But the two Object3 highlighted in red are grouped together instead. Here is the XML Plan. ...
0
votes
1answer
25 views

SQL Server Management Studio - Processor counters for different sessions do not add up

In SQL Server Management Studio, I have two sessions. The workload for each session is: Session 1: while loop to select top items from one table; Session 2: while loop to update statistics of ...
7
votes
3answers
471 views

Single service account running all SQL Servers

Is there any negative performance impact for using the same service account and agent account to run SQL Server and SQL Agent respectively for all SQL server instances running at a small company of ...
1
vote
0answers
115 views

HASH JOIN hint doesn't work. but OPTION (HASH JOIN) does [closed]

I have a query involving 3 tables and 2 inner joins. The optimiser is choosing to join them together with LOOP joins, but I know HASH joins will be better. So I tried changing the joins to be INNER ...
0
votes
0answers
22 views

one Comment table for all content types or many tables for each content type

I have a very similar question with this stack overflow link but since its not answered I had to post it again. I have many place which people can place comment: file download, biography, blog and etc....
3
votes
1answer
70 views

Foreign Key Constraint Set Back to Trusted

We have some production tables with numerous constraints that are not trusted at the moment. We're having them checked/trusted so they can be used again. We know that the optimizer has not been ...
0
votes
1answer
31 views

Bulk Update Based Off Values In A Table

In Sql Server 2014 I need to run an Update statement that will update NULL values with values found previously in the table. To better illustrate, here is a very small subset of my data Create Table ...
-1
votes
0answers
36 views

sp_Blitz github documentation [closed]

In "Writing sp_Blitz Output to a Table" per the GitHub docs: The docs say the fully qualified table is made up of '@OutputDatabaseName = '', @OutputSchemaName = '', @OutputDatabaseName = ''; 1. That ...
4
votes
4answers
140 views

A few huge instances or many small ones

I recently inherited an environment with around 4000+ databases distributed between 21 instances on 3 huge physical servers. Databases are distributed between different instances based on the name, so ...
17
votes
4answers
2k views

How to limit maximum number of rows in a table to just 1

I have a configuration table in my SQL Server database and this table should only ever have one row. To help future developers understand this I'd like to prevent more than one row of data being added....
1
vote
1answer
39 views

How to check programmatically which replica I'm connected to

I have an AlwaysOn Availability Group on MS-SQLServer (2 replicas) and a C# application which sends queries to the Availability Group Listener. How can I check which replica is responding my queries? ...
1
vote
0answers
17 views

Validation Errors in SSIS Package when columns are mapped correctly

I have a SSIS package that I am working on. As soon as I open the SSIS package I am given the following error: Validation error. Populate Organisations Table: Organisation Table destination: '...
1
vote
1answer
39 views

any better way for data archiving?

I'm in one security company and our history data grows fast, causing data archiving sqls run slower and slower. Say, for the sake of data real-time need, the scripts must run in a high frequency for ...
1
vote
1answer
37 views

Why does SQL Server Mangement Studio not script Indexes by default?

Recently I realized by default, scripting the database does not including indexes, and I have to change the option every time. Could anyone please explain the reason? Is there any insight about this ...
0
votes
2answers
61 views

Backup encryption questions

We're going to be implementing encrypted backups in SQL 2014 soon and I'd like to know the gotchas or lessons encountered by anyone else who has done the same. I've read up at MSDN and elsewhere, ...
0
votes
0answers
26 views

SQL Server - Copy Database fails due to duplicate user

In the "model" system database, I have a user (UserA). I have another database with UserA in its Security > Users that I'd like to make a copy of using the Tasks > Copy Database. When I try this I get ...
0
votes
1answer
34 views

Read MS Sql query high latency w.r.t. Remote Query

I'm trying to read a table in a MS SQL Server using python, specifically SQLalchemy, pymssql, and pandas.read_sql. I want to execute the query, put the results into a pandas Dataframe, and continue on ...
1
vote
1answer
53 views

Restoring Database, creating new copy and use existing transaction logs for the original backup database to restore the NEW database to be current?

I am not a DBA nor a database guy, we just recieved a database backup, a differential database backup and daily database transaction logs (each day probably has about 15-20 trans logs). I now have ...
2
votes
2answers
75 views

Should I install SQL Server 2012 SP3 when I'm already running SQL Server 2014?

We've been running SQL Server 2014 for almost a year now, but SQL Server 2012 SP3 continues to appear in the Windows Update list (as an optional install). It seemed ridiculous to install a service ...