Questions tagged [sql-server-2012]

Use this tag for questions specific to the 2012 version of Microsoft's SQL Server.

SQL Server 2012 (codename Denali, version 11.00), released in March 2012, is the successor to SQL Server 2008 R2.

This tag covers questions specific to the 2012 version of the database engine. It is recommended that the tag is also used when tagging questions with this version specific tag.

Programmability topics may include but are not limited to

  • FileTable
  • Semantic search
  • Metadata discovery
  • Ad-hoc Query Pagination
  • Sequence objects
  • Throw statement
  • Conversion functions
    • PARSE
    • TRY_CONVERT
    • TRY_PARSE
  • Date and time functions
    • DATEFROMPARTS
    • DATETIME2FROMPARTS
    • DATETIMEFROMPARTS
    • DATETIMEOFFSETFROMPARTS
    • EOMONTH
    • SMALLDATETIMEFROMPARTS
    • TIMEFROMPARTS
  • Logical functions
    • CHOOSE
    • IIF
  • String functions
    • CONCAT
    • FORMAT
  • Analytic functions
    • CUME_DIST
    • LAST_VALUE
    • PERCENTILE_DISC
    • FIRST_VALUE
    • LEAD
    • PERCENT_RANK
    • LAG
    • PERCENTILE_CONT
17074 questions
68
votes
8 answers

Conversion failed when converting from a character string to uniqueidentifier - Two GUIDs

I don't understand why I can't insert this. I can't spot the problem. The error message is Conversion failed when converting from a character string to uniqueidentifier. The GUIDs are the ones that I got when I did a select from some other…
Simon Edström
  • 6,461
  • 7
  • 32
  • 52
67
votes
7 answers

Why is "close existing connections to destination database" grayed out on SQL Server 2012 Management Studio?

I am normally using SQL Server 2012 Management Studio to restore a SQL Server database from a "bak" file. I do this by overwriting an existing database. In the "Options" page, there is a check-box labeled "Close existing connections to destination…
schlingel
  • 1,514
  • 2
  • 15
  • 24
67
votes
3 answers

sql server restoring back up error

I have backed up a database I had created on an other machine running SQL server 2012 express edition and I wanted to restore it on my machine, which is running the same. I have ticked the checkbox overwriting existing one, and got this…
danarj
  • 1,798
  • 7
  • 26
  • 54
65
votes
5 answers

What is (are) difference between NOLOCK and UNCOMMITTED

I use SQL Server 2012. I write two queries but what is a different between NOLOCK and UnCommitted ? SELECT lastname, firstname FROM HR.Employees with (READUNCOMMITTED) SELECT lastname, firstname FROM HR.Employees with (NoLock)
Ardalan Shahgholi
  • 11,967
  • 21
  • 108
  • 144
64
votes
2 answers

Possible to restore a backup of SQL Server 2014 on SQL Server 2012?

I know that you can't (at least not easily) restore a SQL Server 2012 backup on SQL Server 2008. But how does it work for SQL Server 2014 to SQL Server 2012 ? On database level there is the property to adjust the compatibility mode to any other SQL…
RayofCommand
  • 4,054
  • 17
  • 56
  • 92
63
votes
6 answers

What is the difference between a primary key and a surrogate key?

I googled a lot, but I did not find the exact straight forward answer with an example. Any example for this would be more helpful.
Dom
  • 751
  • 1
  • 5
  • 9
63
votes
12 answers

Convert Date format into DD/MMM/YYYY format in SQL Server

I have a query in SQL, I have to get a date in a format of dd/mm/yy Example: 25/jun/2013. How can I convert it for SQL server?
Krish KvR
  • 1,034
  • 4
  • 11
  • 18
63
votes
3 answers

How to fix the embedded text qualifier issue while exporting data to CSV flat file?

###RFC 4180: RFC 4180 defines Common Format and MIME Type for Comma-Separated Values (CSV) Files. One of the requirements of the RFC 4180 is stated as below. This is the point #7 in the RFC link. If double-quotes are used to enclose fields, then a…
user756519
61
votes
6 answers

Ctrl R not working in SQL Server 2012

In SQL Server 2012, Ctrl+R not working. Any other shortcuts for that. Any setting changes available or is there any alternative?
Yajuvendra Vant
  • 1,127
  • 4
  • 15
  • 33
60
votes
4 answers

Scope of temporary tables in SQL Server

I wrote a stored procedure to import and transform data from one database to another. Each import would take a single company ID and import all data related to this company. To help with the transformation step I use temporary tables. As part of…
Cogslave
  • 2,513
  • 3
  • 25
  • 35
59
votes
3 answers

Identity column value suddenly jumps to 1001 in sql server

I am using Sql server 2012(Denali). I wonder why all identity column values start from 1001 and so on. At the beginning Identity column starts from 1,2 and so on and adding identity smoothly, but suddenly it jumps to 1001,1002 and onwards for all…
Rajaram Shelar
  • 7,537
  • 24
  • 66
  • 107
58
votes
6 answers

Get last 30 day records from today date in SQL Server

I have small question about SQL Server: how to get last 30 days information from this table Sample data: Product: Pdate ---------- 2014-11-20 2014-12-12 2014-11-10 2014-12-13 2014-10-12 2014-11-15 2014-11-14 2014-11-16 2015-01-18 Based on this…
56
votes
1 answer

Cannot Resolve Collation Conflict

I have moved one of our databases (DB1) from SQL Server 2008 to 2012 and when I run the stored procedures I get the following error Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal…
Silentbob
  • 2,805
  • 7
  • 38
  • 70
55
votes
6 answers

How do I add a “last modified” and "created" column in a SQL Server table?

I'm design a new db schema for a SQL Server 2012 database. Each table should get two extra columns called modified and created which should be automatically change as soon a row gets inserted or updated. I don't know how rather the best way to get…
stevo
  • 2,164
  • 4
  • 23
  • 33
55
votes
15 answers

SSIS Excel Connection Manager failed to Connect to the Source

I have a server that is capable of creating and running an Excel Import task using the Import Wizard. I am trying to automate that process by using a visual Studio 2010 Integration Services package, that I am developing on that server. The problem…