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
17
votes
8 answers

More than 2 columns in a CONCAT function

In SQL Server 2012 I want to concat 5 columns into 1 but in the query it works but when I put in in a view it gives me an error like Msg 174, Level 15, State 1, Line 3 The CONCAT function requires 2 argument(s). What's the problem so I can fix…
Jeroen
  • 269
  • 2
  • 3
  • 13
16
votes
3 answers

Listing all sequences in a SQL Server database

I tried: SELECT * FROM sys.sequences I get: Error: The "variant" data type is not supported. SQLState: 08S01 ErrorCode: 0 I know there are sequences. Is there a way to see sequences of a table in SQL Server Management Studio in the GUI…
Steve Waters
  • 3,348
  • 9
  • 54
  • 94
16
votes
2 answers

Isolation Level for stored procedure SQL Server?

I want to add Isolation level in my procedure and for that I wanted to confirm that which one is the correct format from below: Attempt #1 - setting isolation level before calling the stored procedure: SET TRANSACTION ISOLATION LEVEL READ…
Boss
  • 195
  • 1
  • 1
  • 7
16
votes
5 answers

How to split one column into two columns in SQL Server

I have small question about SQL Server, please tell me how to solve this issue Table: emp id name --------------- 1 abc_rao 2 nani 3 hari_babu 4 kalibabu 5 ab_tan Based on that table I want output like below …
user3224208
  • 907
  • 2
  • 9
  • 12
16
votes
1 answer

Decimal out of range

I'm trying to store the decimal 140.2705893427 into a SQL Server 2012 table. The column has a data type of decimal(12, 10) but I get the error: {"Parameter value '140.2705893427' is out of range."} Why is this?
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
16
votes
6 answers

Sql server - recursive delete

I'm trying to delete user's data and all it's related data that is located in different tables. All the tables have Foreign Keys but without cascade delete. I investigated some options: Enable cascade delete on all FK, delete and remove the…
ron
  • 625
  • 2
  • 6
  • 17
16
votes
1 answer

Date time conversion from timezone to timezone in sql server

I having an column of UNIX time stamp in my database table, which comes from a system that is in the Kuwait time zone. My database server's time zone is Eastern Time US & Canada. Now I need to convert the UNIX time stamp in to Kuwait time zone date…
Ashish Rathore
  • 2,546
  • 9
  • 55
  • 91
16
votes
2 answers

Using MVC 4 SimpleMembership with an existing database-first EF model

I am trying to use SimpleMembership in my MVC 4 for the first time and I already have an existing database and EF5 model created based on it! I searched a lot but I cant find how I could use it in my case and also to have everything under my own…
16
votes
4 answers

Are there any benefits to using sql_variant over varchar in SQL Server?

I currently have a database table setup as follows (EAV - business reasons are valid): Id - int (PK) Key - unique, varchar(15) Value - varchar(1000) This allows me to add in mixed values into my databse as key/value pairs. For example: 1 | 'Some…
myermian
  • 31,823
  • 24
  • 123
  • 215
16
votes
3 answers

EF: How do I call SaveChanges twice inside a transaction?

Using Entity Framework (code first in my case), I have an operation that requires me to call SaveChanges to update one object in the DB, and then SaveChanges again to update another object. (I need the first SaveChanges to resolve an issue where EF…
16
votes
4 answers

SQL Server Management Studio crashes after opening or creating database diagram

I have an error message that occurs every time I use SQL Server 2012 Management Studio to open or create a new database diagram, followed by an automatic restart of SSMS. The error message is Attempted to read or write protected memory. This is…
ArmorCode
  • 739
  • 4
  • 15
  • 33
16
votes
4 answers

SQL Stairstep Query

I need some help producing a MS SQL 2012 query that will match the desired stair-step output. The rows summarize data by one date range (account submission date month), and the columns summarize it by another date range (payment date month) Table…
Nathan
  • 431
  • 2
  • 10
15
votes
2 answers

Pass a table variable to a SQL Server stored procedure

I'm trying to pass a table variable to a stored procedure and I get the error: Operand type clash: table is incompatible with TY_MyType Here are the relevant pieces of code: 1 - Type Definition CREATE TYPE [dbo].[TY_MyType] AS TABLE( …
FDavidov
  • 3,505
  • 6
  • 23
  • 59
15
votes
1 answer

DateTime.Kind set to unspecified, not UTC, upon loading from database

When I create a Buyin object the response from the ASP.NET MVC controller, (return Json(response, JsonRequestBehavior.AllowGet);, looks like this: "Buyin": { "Id": 95, "PlayerSessionId": 88, "PlayerId": 45, …
Westerlund.io
  • 2,743
  • 5
  • 30
  • 37
15
votes
4 answers

How to save SQL query result to XML file on disk

I would like to export table from SQL Server 2012 to XML file. I have found nice answer and here how to make XML result from SQL Server database query, but still I am missing how to save this result physically into file. SQL query is: SELECT…
Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148