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
22
votes
6 answers

SQL Server: Best way to concatenate multiple columns?

I am trying to concatenate multiple columns in a query in SQL Server 11.00.3393. I tried the new function CONCAT() but it's not working when I use more than two columns. So I wonder if that's the best way to solve the problem: SELECT…
D. Caan
  • 1,907
  • 6
  • 22
  • 36
22
votes
4 answers

TRY_CONVERT fails on SQL Server 2012

The following SQL statement fails on SQL Server 2012(SP1) 11.0.3401.0 Version DECLARE @b VARCHAR(10) = '12312.2' SELECT TRY_CONVERT(DECIMAL(10,2),@b) error message Msg 195, Level 15, State 10, Line 2 'DECIMAL' is not a recognized built-in function…
user275683
22
votes
5 answers

Get total row count while paging

I have a search screen where the user has 5 filters to search on. I constructed a dynamic query, based on these filter values, and page 10 results at a time. This is working fine in SQL2012 using OFFSET and FETCH, but I'm using two queries to do…
user788312
  • 439
  • 2
  • 10
  • 22
22
votes
5 answers

How to get Previous Value for Null Values

I have the Below Data in my Table. | Id | FeeModeId |Name | Amount| --------------------------------------------- | 1 | NULL | NULL | 20 | | 2 | 1 | Quarter-1 | 5000 | | 3 | NULL …
Shahid Iqbal
  • 2,095
  • 8
  • 31
  • 51
22
votes
4 answers

SQL2012 LocalDB: how to check in c# if it is currently installed?

How to check in c# code if LocalDB currently installed? also, how to check if SQLNCLI11 presents in system?
ZedZip
  • 5,794
  • 15
  • 66
  • 119
21
votes
6 answers

Use RAND() in User Defined Function

I am trying to create a user defined function which calls the system RAND() function inside it, when I try to create the function it errors out with the following message: Msg 443, Level 16, State 1, Procedure getNumber, Line 10 Invalid use of a…
Jack Jones
  • 335
  • 1
  • 2
  • 8
21
votes
1 answer

What does persisted mean in SQL Server 2012

I have a query in SQL Server like this Alter table inventory Add totalitems as iteminstore + iteminwarehouse PERSISTED` What is the advantage of writing the persisted?
Hare Rama Hare Krishna
  • 1,025
  • 5
  • 14
  • 19
21
votes
3 answers

Update or insert of view or function failed because it contains a derived or constant field

I have been trying to understand what is wrong with the following view, and unfortunately I was not able to find my answer anywhere, other than using triggers, which I would like to avoid. Given the following view, when I try to insert into it I get…
user3800174
  • 309
  • 1
  • 3
  • 8
21
votes
1 answer

Why does "select count(*)" from nothing return 1

With SQL Server 2012 : use master select * yields Must specify table to select from which is exactly what I would expect. But the funny thing is that use master select count(*) returns 1. Can someone explain to me what is counted here? Edit :…
Johnny5
  • 6,664
  • 3
  • 45
  • 78
21
votes
6 answers

Group All Related Records in Many to Many Relationship, SQL graph connected components

Hopefully I'm missing a simple solution to this. I have two tables. One contains a list of companies. The second contains a list of publishers. The mapping between the two is many to many. What I would like to do is bundle or group all of the…
James Frost
  • 211
  • 2
  • 4
21
votes
3 answers

Why does adding an unnecessary ToList() drastically speed this LINQ query up?

Why does forcing materialization using ToList() make my query orders of magnitude faster when, if anything, it should do the exact opposite? 1) Calling First() immediately // "Context" is an Entity Framework DB-first model var query = from…
JoeCool
  • 4,392
  • 11
  • 50
  • 66
21
votes
4 answers

Query all table data and index compression

Does anyone happen to have a generic SQL statement that'll list all of the tables and indexes in a database, along with their current compression setting, for each partition? Thanks. EDIT: This is as far as I got in my attempt to query tables, but…
Barguast
  • 5,926
  • 9
  • 43
  • 73
21
votes
5 answers

IS NULL versus <> 1 SQL bit

I have a bit column on a table in a SQL Server 2012 database. I am trying to retrieve all the rows where this bit column is either NULL or NOT TRUE. This query does not bring back what it should: (returns 0 rows) Select * from table where…
ché
  • 257
  • 1
  • 2
  • 8
21
votes
5 answers

MVC 4 Connectionstring to SQL Server 2012

I've created a brand new MVC 4 application in C# using Visual Studio 2012. I'm trying to connect to a brand new SQL Server 2012 (Standard) instance but I can't seem to get my connection string set correctly. My connection string from my Web.config: …
lhan
  • 4,585
  • 11
  • 60
  • 105
21
votes
5 answers

SSIS: I don't see the package configuration wizard

Using SQLServer 2012 Enterprise, I don't see "Package Configuration Wizard" in SSIS when I do a right click in Control Flow tab. I can see all the other items (Log, Digital Signing...). Here are info about my install: Microsoft Visual Studio…
Francois
  • 10,730
  • 7
  • 47
  • 80