Questions tagged [sql-server-2012]

SQL Server 2012 (major build version 11.00.xxxx). Please also tag sql-server.

SQL Server 2012 was introduced in March 2012. Current build versions include:

  1. 11.00.2100 – RTM
  2. 11.00.3000 – Service Pack 1, released November 2012
  3. 11.00.5058 – Service Pack 2, released June 2014

SQL Server 2012 left mainstream support on 2017-06-11, and will leave extended support on 2022-07-12.

See tag wiki of for more details.

4554 questions
154
votes
12 answers

How do I move SQL Server database files?

I have a database and want to move the .mdf and .ldf files to another location. But I do not want to stop the MSSQLSERVER service, and I do not want to export to another server. How can I do this?
user2645263
98
votes
4 answers

SQL server databases stuck in restoring state

I have a Sharepoint server. We had an issue with our backup tool and now some of my databases are stuck in restoring state! Is it possible to stop the restoring process? and also, How can I make sure the database integrity has not been compromised?…
Pooya Yazdani
  • 1,093
  • 1
  • 8
  • 7
81
votes
5 answers

Are SQL Server in-place upgrades as ill advised as they used to be?

I have been working with SQL server on and off since SQL Server 6.5, the old advice that still rings in my head was never to do an in-place upgrade. I'm currently upgrading my 2008 R2 DEV and TEST systems to SQL Server 2012 and need to use the same…
DamagedGoods
  • 2,589
  • 6
  • 31
  • 48
75
votes
2 answers

How to join a table with a table valued function?

I have a user defined function: create function ut_FooFunc(@fooID bigint, @anotherParam tinyint) returns @tbl Table (Field1 int, Field2 varchar(100)) as begin -- blah blah end Now I want to join this on another table, like so: select f.ID,…
Shaul Behr
  • 2,863
  • 8
  • 30
  • 41
62
votes
6 answers

Date range rolling sum using window functions

I need to calculate a rolling sum over a date range. To illustrate, using the AdventureWorks sample database, the following hypothetical syntax would do exactly what I need: SELECT TH.ProductID, TH.TransactionDate, TH.ActualCost, …
52
votes
4 answers

Check if a user exists in a SQL Server database

I'm working with SQL Server 2012. I want to check if a user exists before adding it to a database. This is what I have tested: USE [MyDatabase] GO IF NOT EXISTS (SELECT name FROM [sys].[server_principals] WHERE name…
VansFannel
  • 1,803
  • 5
  • 22
  • 35
51
votes
2 answers

Does a re-index update statistics?

I've been doing the MS10775A course this past week and one question that came up that the trainer couldn't answer reliably is: Does a re-index update the statistics? We found discussions online arguing both that it does and that it doesn't.
Thor Erik
  • 625
  • 1
  • 5
  • 6
51
votes
4 answers

What are Objective Business Reasons to Prefer SQL Server 2012 over 2008 R2?

My company is facing the decision whether to purchase SQL Server 2012 Denali or SQL Server 2008 R2 for a new database server. I am looking for objective reasons to choose one over the other. Our requirements: Standard edition (for financial reasons…
usr
  • 7,240
  • 5
  • 30
  • 58
48
votes
8 answers

SQL Server Agent Jobs and Availability Groups

I'm looking for best practice in dealing with scheduled SQL Server Agent jobs in SQL Server 2012 availability groups. Maybe I missed something, however at the current state I feel that SQL Server Agent is not really integrated with this great…
45
votes
4 answers

Can I install SQL Server Management Studio locally?

Can I install SQL Server Management Studio on my desktop to access a database on a SQL Server 2012 instance? If so, where can I find the installer? Google searches only return 'express' versions whereas, I am looking for the full SQL Server…
pgunston
  • 665
  • 2
  • 7
  • 10
42
votes
3 answers

Restore SQL Server 2012 backup to a SQL Server 2008 database?

Is there a way to restore a SQL Server 2012 database backup to a SQL Server 2008? I tried to attach file, it does not work.
urlreader
41
votes
8 answers

Is select * still a big no-no on SQL Server 2012?

Back in the days of yesteryear, it was considered a big no-no to do select * from table or select count(*) from table because of the performance hit. Is this still the case in later versions of SQL Server (I'm using 2012, but I guess the question…
Piers Karsenbarg
  • 929
  • 2
  • 11
  • 23
40
votes
2 answers

SQL Server unpredictable select results (dbms error?)

Below is simple example, which returns strange results, that are unpredictable and we cannot explain it in our team. Are we doing something wrong or is it SQL Server error? After some investigation we reduced the search area to union clause in…
Ryszard Bocian
  • 501
  • 5
  • 4
40
votes
2 answers

Optimising plans with XML readers

Executing the query from here to pull the deadlock events out of the default extended events session SELECT CAST ( REPLACE ( REPLACE ( XEventData.XEvent.value ('(data/value)[1]', 'varchar(max)'), '',…
Martin Smith
  • 80,333
  • 15
  • 230
  • 323
39
votes
6 answers

Management Studio System.OutOfMemoryException

I'm using Microsoft SQL Server 2012 and trying to run a simple query against it within Management Studio. I'm getting the following error (in SSMS, running on the server): An error occurred while executing batch. Error message is: Exception of…
Ben Durkin
1
2 3
99 100