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
31
votes
3 answers

Correct way to select from two tables in SQL Server with no common field to join on

Back in the old days, I used to write select statements like this: SELECT table1.columnA, table2.columnA FROM table1, table2 WHERE table1.columnA = 'Some value' However I was told that having comma separated table names in the "FROM" clause is…
volume one
  • 6,800
  • 13
  • 67
  • 146
31
votes
7 answers

Joining two tables with specific columns

I am new to SQL, I know this is really basic but I really do not know how to do it! I am joining two tables, each tables lets say has 5 columns, joining them will give me 10 columns in total which I really do not want. What I want is to select…
Natalia Natalie
  • 647
  • 3
  • 10
  • 17
30
votes
6 answers

SQL LocalDB vs SQL Server CE

I have a small project that will have 1 user on 1 computer. The database will be rather small (probably less than 1 mb of data). I plan to use WPF and Entity Framework for that project. I came up with 2 potential database solutions for my project :…
30
votes
3 answers

What are the main differences between OPTION(OPTIMIZE FOR UNKNOWN) and OPTION(RECOMPILE)?

I run into the classic Parameter Sniffing issues in SQL Server 2012. Based on some research I found multiple options around this problem. The two options that I need to understand the difference between are OPTION(OPTIMIZE FOR UNKNOWN) vs…
Junior
  • 11,602
  • 27
  • 106
  • 212
30
votes
8 answers

SQL Server: datediff function resulted in an overflow when using MILLISECOND

I have the following query : select CONVERT(varchar(12), DATEADD(MILLISECOND, DateDiff(MILLISECOND, '2014-08-04 10:37:28.713','2014-11-04 08:21:17.723'), 0), 114) When I execute this, I get the error : "The datediff function resulted in an…
Bart Schelkens
  • 1,235
  • 4
  • 21
  • 45
30
votes
4 answers

How can I clean up the SSISDB?

When I set this up I overlooked the retention period. My database has become pretty large so I want to decrease it's size. If I simply change the retention period (it was 365) it causes issues with SSIS running my packages. I even changed it in…
Paul Riker
  • 785
  • 2
  • 10
  • 30
30
votes
10 answers

How to restore a SQL Server 2012 database to SQL Server 2008 R2?

I am trying to restore the backup taken from a SQL Server 2012 to SQL Server 2008 R2, and it giving an error Specified cast is not valid. (SqlManagerUI) If you have any solution to this please give comment thanks.
30
votes
7 answers

A connection was successfully established with the server, but then an error occurred during the pre-login handshake in SQL Server 2012

Today I could not log into my local SQL Server 2012 instance with the following error message A connection was successfully established with the server, but then an error occurred during the pre-login handshake. provider: SSL Provider, error: 0 -…
user2816785
  • 301
  • 1
  • 3
  • 3
30
votes
2 answers

Better way for Getting Total Count along with Paging in SQL Server 2012

I have requirement to get the total count of records along with paging. At present I am doing it as listed below in SQL Server 2012. This needs a separate query for getting count. Is there any improved way in SQL Server 2012? ALTER PROCEDURE…
LCJ
  • 22,196
  • 67
  • 260
  • 418
30
votes
2 answers

Why the SQL Server ignore the empty space at the end automatically?

I wrote a query SELECT * FROM Users WHERE UserName = 'admin ' by mistaken typing. But I found that the result is as the same as SELECT * FROM Users WHERE UserName = 'admin' It seems that the empty space at the end is ignored by SQL Server…
Jailu Lee
  • 611
  • 1
  • 8
  • 13
30
votes
5 answers

How do I import a .bak file into Microsoft SQL Server 2012?

Been Googling this for awhile and no answer....can anyone help?
user979331
  • 11,039
  • 73
  • 223
  • 418
29
votes
11 answers

STRING_SPLIT in SQL Server 2012

I have this parameter @ID varchar = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20' I want to do something to split the comma-separated values. The string_split function doesn't work and I get this error: The STRING_SPLIT function is…
Moh
  • 303
  • 1
  • 3
  • 10
29
votes
4 answers

Replace first occurrence of substring in a string in SQL

I have to fetch data from a @temp table which has something like "or ccc or bbb or aaa" I want to replace the first occurrence into space to get something like this " ccc or bbb or aaa". I am trying stuff and replace but they don't seem to get me…
CrazySwazy
  • 403
  • 1
  • 5
  • 11
29
votes
3 answers

SQL Update - Multiple Columns

I would like to update multiple columns in a table based on values from a second table using a Select statement to obtain the values like this: UPDATE tbl1 SET (col1, col2, col3) = (SELECT colA, colB, colC FROM tbl2 …
Prakash Chennupati
  • 3,066
  • 3
  • 27
  • 38
29
votes
3 answers

How can I fix the T-SQL editor in VS 2012 after installing SQL Server 2012 SP1?

I can suddenly no longer open .sql files in VS 2012 by simply double clicking in the Solution Explorer. I get the error message: Unable to open Transact-SQL file in custom editor I strongly suspect this is after installing SP1 for SQL Server 2012…
ProfK
  • 49,207
  • 121
  • 399
  • 775