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
1 answer

SQL Server Rolling Rank

I have a table of stock prices for different dates. DECLARE @table TABLE (MyDate DATE, Ticker VarChar(6), Price Decimal (6,2)) INSERT INTO @Table VALUES ('1/1/13' , 'ABC' , '100.00') ,('1/2/13' , 'ABC' , '101.50') ,('1/3/13'…
Coding_Newbie
  • 365
  • 1
  • 3
  • 11
3
votes
2 answers

Using a subset of data as the target of a MERGE

currently, we're merging against esqlProductTarget: MERGE esqlProductTarget T USING esqlProductSource S ON (S.ProductID = T.ProductID) WHEN MATCHED THEN UPDATE SET T.Name = S.Name, T.ProductNumber = S.ProductNumber, …
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
3
votes
2 answers

Pivot table with multiple column in sql?

i want to pivot my table with multiple column bdate th_name amt NetSale GST Occupancy 3/18/18 12:00 AM Screen 1 212540 169474.1128 43065.88718 1752 3/18/18 12:00 AM Screen 2 242585 193562.5 49022.5 …
3
votes
0 answers

SQL .Net StoredProcedure error on serialization

When I execute the SP CLR from this example, on SQL Server version 11.0.3128 (basically 2012 + SP1), sometime I got the following error, and sometime not : Msg 6522, Level 16, State 1, Line 1 A .NET Framework error occurred during execution of…
Jimbot
  • 696
  • 5
  • 20
3
votes
2 answers

rowversion skips an integer after 0xFF

According to the rowversion docs Each database has a counter that is incremented for each insert or update operation that is performed on a table that contains a rowversion column within the database. however this 'increment' skips an integer…
wal
  • 17,409
  • 8
  • 74
  • 109
3
votes
1 answer

SQL Server 2012 tells me Agent XPs component is turned off but SQL Agent is running

I have a very strange situation on SQL Server that I cannot fathom out. Environment : SQL Server 2012 SP3 CU3 running on a 2 node Windows 2008 R2 cluster In SQL Server Management Studio\Management\Maintenance Plans\ I am unable to create or edit…
perrydyball
  • 41
  • 1
  • 4
3
votes
1 answer

finding int_ids that have more than one row with a flag set to Y

I have a table that can store multiple descriptions for each code. However there is a flag in that table that is to indicate which of those is the main or primary description. In some instances, we have codes that have more than one with this flag…
3
votes
2 answers

SQL Server: How to CROSS JOIN between 2 Columns of the same table? ( Each Column contains Delimited Values)

I have a table with around 3000 rows. It looks like the one below. Delimited_Col_1 | Delimited_Col_2 | Date ----------------|-----------------|---------- a | x1,x2 | Date-1 b,c | y1,y2,y3 | Date-2 …
3
votes
3 answers

How to return a column with concatenated identifier

I have two tables with some unique and some duplicate entries. I need to UNION those tables and output an additional column, that concatenates a tableidentifier the row was found in. Please find an example here:…
Ksdmg
  • 397
  • 5
  • 15
3
votes
1 answer

Order child items in a certain order in a multi-level hierarchy query in SQL Server 2012

I have a table in SQL Server 2012 called Items which contains different items that are related to each other in a parent-child relationship through ParentId column. This table contains a topmost level item with ItemId of 429965 and its children,…
Sunil
  • 20,653
  • 28
  • 112
  • 197
3
votes
3 answers

How can I get data in single row when multiple columns data have null in some columns?

How can I get data in single row when multiple columns data have null in some columns? Following is the scenario col1 col2 col3 col4 ----- ------ --------------- 1 NULL NULL NULL NULL 2 NULL NULL NULL NULL 3 …
Abhijeet
  • 101
  • 6
3
votes
1 answer

Running Average for stock using Recursive CTE

I have the below data and need to calculate the running average for each row using the amount from each of the previous rows. CREATE TABLE [dbo].[AKTest]( [IntakeSellingPrice] [decimal](38, 20) NULL, [IntakeSellingAmount] [decimal](38, 6)…
user3266033
  • 157
  • 1
  • 2
  • 12
3
votes
1 answer

How to subtract consecutive rows from different tables in MS SQL Server 2012?

I have a main table (table0 from database0) in SQL Server 2012 where I store information about job objects. Each job has unique ID and has only one entry (row) in the main table. Each modification on job object makes a new row in different table…
InstantE
  • 31
  • 3
3
votes
1 answer

Could not allocate space for object in database because the 'PRIMARY' filegroup is full

Could not allocate space for object in database because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for…
Ram Bhatt
  • 81
  • 1
  • 11
3
votes
2 answers

Normalize a row of data in a query - Turn one row into many

Is there a better way of doing this , I am using SQL Server 2012. I have a table built by as vendor that looks like the below: Customer, Date, Desc1, Qty1, Price1, Desc2, Qty2, Price2, Desc3, Qty3, Price3 I want a result set that returns…