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

JSON_VALUE for SQL Server 2012?

I want to extract values from a JSON string in SQL. Started to write a function to do so but then I thought "surely someone else has already done this?". I was super excited when I saw there is a JSON_VALUE function in SQL Server now... but then…
BVernon
  • 3,205
  • 5
  • 28
  • 64
3
votes
1 answer

Merge multiple SQL files into a single SQL file

I want to merge multiple SQL files into a single SQL file. All I could find over the internet is to create a batch file and execute all the files. However, I want to create a single script file. Any help would be appreciated? Also, can this be done…
Sid M
  • 4,354
  • 4
  • 30
  • 50
3
votes
2 answers

Find max column name and value for each row

I need to find the question with the lowest score. The data has columns for Yes and No points which are used to calculate a total score. I not only need to know the lowest score but also which question number had the lowest score. The scores are all…
Hannover Fist
  • 10,393
  • 1
  • 18
  • 39
3
votes
0 answers

Arithmetic Overflow error converting to data type int while reorganizing index in SQL Server

We have a table of 3+ billion rows and one of the non clustered indexes that we are trying to reorganize contains only one numeric(18,0) column. It is a foreign key column and recently went past the threshold for reorganization. I was wondering if…
3
votes
1 answer

Compatibility mode allows new command?

I have a SQL Server 2017 server running a database in 2012 compatibility mode. However when I try using the new to 2017 T-SQL command string_agg(), it works. I would expect a syntax error because string_agg() isn't valid for 2012 mode. Here is the…
KM.
  • 101,727
  • 34
  • 178
  • 212
3
votes
1 answer

How to use EXISTS and NOT EXISTS in one query?

Table1 Id Name DemoID 1 a 33 2 b 44 3 c 33 4 d 33 5 e 44 Table2 Id DemoID IsTrue 11 33 1 12 44 1 Table3 Id Table1_ID 11 1 Now we can find which DemoID is present in Table2 using below query - SELECT…
Neo
  • 15,491
  • 59
  • 215
  • 405
3
votes
2 answers

Parsing multiple pipe delimited columns into rows while retaining appropriate alignment and ID

I'm being forced to worth with data that is presented with a unique ID, and a number of columns. Some of these columns themselves contain additional detail about 'sub' records, and these are pipe delimited fields. I'm presenting a modified/generic…
RyanL
  • 1,246
  • 2
  • 10
  • 14
3
votes
1 answer

Relational Database Design - User favorite DB design

Use case : Save user favorite combination to database. A user can select 1."a,b,c" as his first favorite combination. 2."a,b" as second favorite combination. How to design a DB table for saving this information and also should be able to retrieve…
Karthik Suresh
  • 367
  • 7
  • 23
3
votes
1 answer

Error in collate SQL_Latin1_General_CP850_BIN2 with UTF-8 SQL Server

I'm trying to select a column from my database that has SAP's informations. But when I execute my select all my special characters as 'À Ê' are broken, for example: TELECOMUNICAÃiES (INCLUI ASSIST-NCIA T+CNICA) should be TELECOMUNICAÇÕES (INCLUI…
3
votes
2 answers

Create query for below output using pivot

I want to pivot my table with multiple columns as per below requirement. Employee_ID ProcessingMonth Amount FinancialYear 3 April 41668.00 2017 3 June 41668.00 2017 3 March …
3
votes
2 answers

Paginating a parent in SQL Server on a parent/child query

(SQL Server 2012 - Web Edition) I have a parent/child (one to many) relationship in a query like so: SELECT a.a, a.b, b.c FROM tablea INNER JOIN tableb ON b.pk = a.fk I have a huge pagination query that encompasses this using the standard…
dudeinco
  • 165
  • 1
  • 11
3
votes
0 answers

SqlCmd variable reference is not allowed in object names

I'm creating a visual studio database project. In one of the script, I want to achieve something like CREATE USER [$(DatabaseName)\UserX] WITHOUT LOGIN WITH DEFAULT_SCHEMA = dbo Which popups error SQL70604: SqlCmd variable reference is…
Circle Hsiao
  • 1,497
  • 4
  • 22
  • 37
3
votes
1 answer

SQL Merge output both matched and unmatched results

I have two keys for data, pk is supposed to be generated from database when a row is inserted, while fk is a complex key which is given by another system. I would like to produce a pk key for each fk key. CREATE TABLE test_target ( [pk] [INT]…
Hsu Siu Fai
  • 33
  • 1
  • 3
3
votes
1 answer

Variable is not updated in SSIS For Each Loop

I'm trying to create simple project in which I'd like to download XML files from given website. I have stored files names in DataBase table. What I have done looking at this tutorial: Implementing Foreach Looping Logic in SSIS is: a. Read all…
DKM
  • 270
  • 3
  • 13
3
votes
2 answers

How to make SQL query to get parent child data in group

I have one customer table, and have parent and sub customer in same table with "ParentId" field relation. Table as below. CustId CustName ParentId ---------------------------------- 1 Cust1 0 2 Cust2 0 3 …
tgeek001
  • 95
  • 1
  • 7