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
4answers
158 views

Add autoincrement to existing PK

I created a table in a DB that already exists in another DB. It was initially populated with the old DB data. The table's PK had to receive the values that already exist on those records, so it ...
4
votes
3answers
62 views

In what cases a transaction can be committed from inside the CATCH block when XACT_ABORT is set to ON?

Edit After getting first answers to this question I realised that I should narrow it down and changed the title of the question. Sorry for confusion. I've been reading MSDN about TRY...CATCH and ...
0
votes
2answers
7k views

How to copy backup files to remote share in SQL Server Agent job without AD/domain accounts involvement?

MS SQL Server 2012... with nightly databases backups to the same/local as SQL Server machine... I am trying to add another SQL Server Agent Job to copy the .bak files to remote (non-windows, i.e. ...
0
votes
2answers
5 views

Create new instance MS SQL Server 2014

I have installed MS SQL Server 2014 , but after installation there is no instance created. There is only the default instance. How make a new instance in existing MS Sql Server ? I found a lot of ...
32
votes
5answers
4k views

Why does adding a TOP 1 dramatically worsen performance?

I have a fairly simple query SELECT TOP 1 dc.DOCUMENT_ID, dc.COPIES, dc.REQUESTOR, dc.D_ID, cj.FILE_NUMBER FROM DOCUMENT_QUEUE dc JOIN CORRESPONDENCE_JOURNAL cj ...
7
votes
2answers
282 views

SUM of DATALENGTHs not matching table size from sys.allocation_units

I was under the impression that if I were to sum the DATALENGTH() of all fields for all records in a table that I would get the total size of the table. Am I mistaken? SELECT SUM(DATALENGTH(Field1)) ...
1
vote
0answers
37 views

Having hard time understanding expressions in below query plan

I was going through Temporal tables new features in SQL 2016,one of the examples was to query tables with as of clause which returned below query plan Rows Executes StmtText StmtId NodeId ...
0
votes
1answer
15 views

How do I view operators in a Notify Operator task in a Maintenance Plan?

In the past, we have added each DBA to a Notify Operator task on failure in Maintenance Plans ranging from scheduled backups to indexing and occasionally one-off operations. One of our DBAs recently ...
0
votes
1answer
36 views

Select Into removes IDENTITY property from target table

I am doing an exercise which removes the IDENTITY property from the target table when using a select into statement. source table name: Sales.Orders column name: orderid column property: int ...
3
votes
1answer
129 views

SQL Server query on server taking longer than laptop

Our program uses an SQL server database as its back-end (SQL server 2008-r2 - 2014). The program is OK for performance but the Database seems to slow down a bit too much. As part of the nightly ...
5
votes
2answers
668 views

Maximum SQL Server memory set to 12 GB, but it still goes over 12 GB. How do I prevent SQL Server going over max memory limit?

User 'mrdenny' wrote that after you set SQL Server maximum memory... Now this isn't going to limit all aspects of SQL Server to that amount of memory. This only controls the buffer pool and the ...
1
vote
1answer
105 views

What is the relationship between the SSIS Package Store and Catalog?

I have a server with a working installation of the Sql Server 2012 SSIS Catalog. I need to set up an additional instance including the SSIS Package Store service as an interim step while the packages ...
1
vote
1answer
26 views

Fill Factor: Will the fill factor change automatically after it detects the changes in the index pages?

So lets say that the default fill factor is left at 0 initially. Data has been loaded up into the server and one fine weekend, the index rebuild job is run. Now if it detects any new data which must ...
1
vote
1answer
36 views

Readable secondary

I set my readable secondary to read intent only and I ran my application without application intent = readonly and start a trace on the secondary node to make sure we are not reading from the ...
1
vote
0answers
19 views

Blocking Extended events

I have very basic table CREATE TABLE [dbo].[Table_1]( [Test] [int] NULL) sp_configure'block process threshold', 1 --> 1 sec go To create blocking, in 1 session i executed Begin tran Update ...
2
votes
0answers
23 views

How to deal with Users Needing to Enter Mixed Data Types in MS SQL Server

I have a form in a C# application that I can't change with a data table bound to a query. The user enters a mark for a student's task or 'A' for absent. However, the person who designed this had the ...
4
votes
1answer
230 views

Find all tables that are related to a view recursively sql server

I have a view-A that is comprised of other views (View-B View-C) and I would like to list all the tables that used by View-A (which would include the tables used in View-B and View-C). When I use ...
4
votes
1answer
50 views

How can I select all of the parents of rows that exist in another table?

I have two tables that share a many to many relationship. The relationships are stored in a third table. CREATE TABLE Person ( Id int NOT NULL, Name varchar(255) NOT NULL, PRIMARY KEY ...
2
votes
1answer
38 views

Error 909 restoring a database on Standard Edition

I ran into a problem with SQL Server 2012 Standard Edition (64-bit). I have rebuilt a system with the exact same specifications for software as it had been built previously (Windows 2012, SQL Server ...
0
votes
0answers
32 views

Retrieving the latest forecast

I am writing an application which stores weather forecasts for different cities, and each day there is a new forecast for each city. I want to be able to provide daily forecasts, and also the latest ...
3
votes
1answer
30 views

SQL Server 2008 R2 services not coming online

I am working for a critical account and yesterday I got a weird issue after applying cumulative update package 14 on top of SQL Server 2008 R2 Standard edition. Before applying CU-14 package on the ...
2
votes
1answer
25 views

Installation of SQL Server 2014 fails on Windows Server 2012 R2

I am attempting to run a silent installation of SQL Server 2014 with SP1 on Windows Server 2012 R2 core install, although it also fails when using UIMODE="EnableUIOnServerCore": (01) 2016-02-05 ...
4
votes
2answers
54 views

Transaction Log Backups Serial or Parallel?

We happen to be using SQL Server 2012 Standard Edition. I also happen to use Ola Hallengren's scripts to provide an easy, more flexible framework for doing backups and maintenance. This question ...
1
vote
2answers
103 views

Transforming multiple rows into a single row

In my company, I need to join table A to table B: Table A is the sources table Table B is the empty table I want to know that how can I do it and the result like table B? Source table A: ID ...
1
vote
1answer
129 views

Best way to transfer a few tables from reserve server to production

We have two MS SQL Servers (2012 Standard Edition on Windows 2012 Server) which are located in the same subnet. One is production server. Another is reserve server. Currently there is a ...
2
votes
2answers
102 views

Issues installing SQL Server 2008 R2 or any other version on Windows 10

I have a serious problem by installing any SQL Server version (tried 2008 R2 and SQL Server 2014) on Windows 10. First question: are the above mentioned versions compatible with Windows 10 or Windows ...
4
votes
2answers
2k views

How to find which edition the SQL Server installation media belongs to

Without installing SQL Server media 2008 and 2012, how can we know that the media belongs to a certain edition (like Developer, Standard or Enterprise)?
0
votes
0answers
34 views

Headers and footers for Crystal Reports [on hold]

I have three tables: Employee [EMPNAME, EMPID] ProductList [ProductName, ProductCode] Orders [EMPNAME, ProductCode, ProductName, DeliveryDate, OrderDate, TOTAMT] I am trying to ...
3
votes
1answer
82 views

Translate query using APPLY to run under compatibility level 80

I want to use the following query: SELECT SUBSTRING(qt.TEXT, ( qs.statement_start_offset / 2 ) + 1, ( ( CASE qs.statement_end_offset WHEN -1 THEN DATALENGTH(qt.TEXT) ...
0
votes
1answer
129 views

Application is hanging when database upgraded from SQL Server 2000 to SQL Server 2008 R2

Presently we are working with SQL Server 2000, the database is perfectly working with our software for retail sales counter application developed with VB 6.0. But after upgraded to SQL Server 2008 R2, ...
2
votes
1answer
156 views

sys.dm_db_index_physical_stats is extremly slow

I have a database that is around 4.5TB, since we have parallel inserts (to reduce daily load time) on one table (partitioned by month) the clustered index on this table tends to be heavily fragmented. ...
11
votes
1answer
184 views

stats_column_id and index_column_id do not update with physical order of clustered index is changed

Unless I'm misunderstanding the purpose of the column, the following code indicates that a change of the structure of the clustered index does not change the ordinal position (stats_column_id)of the ...
2
votes
1answer
173 views

Can SQL Server 2008 R2 get email name resolution from Office 365?

We just moved from an on premise Exchange server to Office 365's Exchange Online. My question is, is there any way to still get email name resolution from Office 365? I have many stored procedures ...
3
votes
1answer
167 views

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

I have an Operations server running Windows Server 2012R2 and SQL Server 2014 Enterprise back end. This server is used to deploy new code to other production servers via cmd file called by a SQL ...
16
votes
1answer
114 views

Setting BUFFERCOUNT, BLOCKSIZE, and MAXTRANSFERSIZE for BACKUP command

I am looking for practical guidance for setting the values for the BUFFERCOUNT, BLOCKSIZE, and MAXTRANSFERSIZE of the BACKUP command. I have done a bit of research (see below), I have done a bit of ...
6
votes
2answers
935 views

Executing Powershell SMO against a cluster with elevated privileges to update service accounts

I'm working on a Powershell script to update service accounts on named SQL instances in a failover cluster. I'm trying to use the SMO and WMI to update this so that I can update the service account ...
1
vote
2answers
49 views

Query to send mail to multiple users with their corresponding tickets

I have a table which has a list of ticket owners and and tickets which are assigned to them which are of high priority. For example: I need to send mail from SQL Server using sp_send_dbmail to ...
7
votes
2answers
2k views

Shared Lock issued on IsolationLevel.ReadUncommitted

I read that if I use IsolationLevel.ReadUncommitted, the query should not issue any locks. However, when I tested this, I saw the following lock: Resource_Type: HOBT Request_Mode: S (Shared) ...
0
votes
0answers
15 views

Check for impersonated users using Policy Management

All: I apologize in advance for my poorly worded question, but I'm very new to using policy management and was wondering if there is a way that you can check for impersonated users using Policy-based ...
-8
votes
1answer
125 views

How can I intentionally grow my transaction log to 500GB for testing purposes? [on hold]

I have been tasked with creating a 500GB transaction log with the intention of developing an automated transaction-log shrinker. I need to be able to record the time take for this task. How can I ...
0
votes
1answer
23 views

EXEC master.dbo.xp_cmdshell 'The user name or password is incorrect'

I am trying to move a file from a network drive to another server and when I execute this statement. I get an output of The user name or password is incorrect DECLARE @SourceFile AS ...
6
votes
2answers
163 views

Running sp_AskBrent with @ExpertMode = 1 in PowerShell

I am trying to run sp_AskBrent from PowerShell using Invoke-SQLCmd and capture its output in a variable: $query = "EXEC SAIDBA.monitoring.sp_AskBrent @Seconds=10;" $check = Invoke-Sqlcmd ...
0
votes
0answers
25 views

SQL Server Transactional Replication Not Being Created

I'm trying to set up transactional replication between two instances of SQL Server 2014. The publisher is a named instance running SQL Server 2014 Standard Edition. The subscriber is an instance of ...
10
votes
1answer
187 views

How to export the output of sp_AskBrent?

We have an instance that randomly spikes the CPU. I want to create an alert that fires on CPU over 90% and automatically calls a job that runs sp_AskBrent and emails me the output. However, the output ...
5
votes
2answers
89 views

Unable to create restore plan due to break in LSN chain

My backup plan is: Full backup - once a day Differential backup - every four hours Transaction Log backup - every 30 minutes. All database backup are stored on my computer. I add some wrong ...
3
votes
1answer
50 views

Advice on how to improve the efficiency of a stored procedure using lots of joins

I have a stored procedure that is returning search results for items in a database grouped by customers who own them. The user performing the search is restricted as to what items they can see by ...
-1
votes
1answer
38 views

SQL Server installation location [on hold]

What is the best practice recommendations for installing SQL Server 2012 or 2014 with regards the installation files location. Can the installation files location resides on the system drive or should ...
1
vote
2answers
94 views

Which data type should I use to store a 11 digit number [on hold]

Which data type I should use to store an 11 digit number? It must store '0' as the first digit. For example, if I store 02421402015, it must show 02421402015. I tried using varchar and it shows ...
3
votes
0answers
25 views

How to change default port for T-SQL Debugger

The default port for T-SQL Debugger is 135, it is possible to change this port ? In my company this port is on special list of banned ports, therefore we need to open that service on another port ...
0
votes
2answers
2k views

MSSQL Restore Database is terminating abnormally

When I'm trying to restore a database, I'm getting this error in MSSQL: Msg 3287, Level 16, State 1, Line 16 The file ID 1 on device ...