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

SQL Server: detect inventory changes

I have a simple inventory table: IF OBJECT_ID('tempdb.dbo.#t') IS NOT NULL DROP TABLE #t GO CREATE TABLE #t ( [date] DATE, Item VARCHAR(1), [Location] INT, Qty INT ) INSERT INTO #t ([date], [Item], [Location], [Qty]) VALUES…
rasenkantenstein
  • 357
  • 1
  • 2
  • 16
3
votes
1 answer

Data lineage in SQL Server Denali

I see a lot of mentioning of the new feature "Data lineage and Impact Analysis" in SQL Server codename Denali, nevertheless all my attempts to make this feature work seem to result in failures. Did anyone managed to make it work or came across a…
wildberry
  • 90
  • 1
  • 7
3
votes
3 answers

convert rows to columns using date column

I have a table containing four rows: id(primary key, auto increment), value, type and time. id value type time 1 1.2 1 2017-10-26 16:16:49.350 2 12.4 2 2017-10-26 16:16:49.350 3 0.6 3 2017-10-26 16:16:49.350 4 …
3
votes
4 answers

Does it make a difference in SQL Server whether to use a TinyInt or Bit? Both in size and query performance

I have a table that has 124,387,133 rows each row has 59 columns and of those 59, 18 of the columns are TinyInt data type and all row values are either 0 or 1. Some of the TinyInt columns are used in indexes and some are not. My question will it…
3
votes
3 answers

Get max of each month of the last 3 years to select the record month

We are using MS SQL SERVER 2012. We are recording like everytime a user makes a phone call, by adding a Datetime and Userid into a table for each call the user makes. Now I need to calculate the top monthly, weekly, daily record from the users off…
Developer
  • 81
  • 1
  • 7
3
votes
1 answer

How to avoid the "Incorrect syntax near 'OFFSET'. Invalid usage of the option NEXT in the FETCH statement."

I am working on an ASP.NET MVC 5 web application which uses Entity Framework version 6. Now I develop the application on SQL Server 2012 inside my development server. I mapped my database tables and I generate the .edmx model file. Everything is…
3
votes
1 answer

Want to pivot table. And generate dynamic SQL string and execute it

Create table script CREATE TABLE #TableA ( A VARCHAR(50), Allocations INT, Seats INT, EndDate DATETIME ); Insert table script INSERT INTO #TableA VALUES ('ABC',450,23,'2017-10-05'), …
3
votes
1 answer

SQL Round Number with Over()

I have a pretty basic sql query query that is doing a calculation on the total number of records returned from a grouped result set. SELECT vco.OutcomeName, vco.VersionCompareOutcomeID, COUNT(t.OutcomeName) AS Total, …
SBB
  • 8,560
  • 30
  • 108
  • 223
3
votes
3 answers

Including nvarchar(max) columns in select clause dramatically increases execution time

I have simple table that consists of the columns and indexes as shown at below. Here is my index created upon recommendation of sql database engine tuning advisor.It includes all columns. CREATE NONCLUSTERED INDEX…
erhan355
  • 806
  • 11
  • 23
3
votes
2 answers

How to get Count under specific condtion in addition to the main conditions?

I don't know if this is possible, but i want to get a count under a specific condition which is different from the main query. If i have Two tables like this : Overtime emp_num, dep_code, trans_date, overtime shift_id 13 …
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
3
votes
2 answers

Filter records using CAST() and sub query in SQL Server

I am stuck with a scenario where I need to cast a particular column as BIGINT and check whether the number is not greater than X, but, the column will not always have numeric values. I tried the following approach but it is throwing an error. …
RandomUser
  • 1,843
  • 8
  • 33
  • 65
3
votes
1 answer

SQL Server 2012:Generate column values Dynamically based on concatenation of other column values

I need to generate common backup codes based on the available backup products across the table. Below is the backup product table if object_id('tempdb..#pdt') is not null DROP TABLE #pdt create table #pdt(ROW_NUM INT IDENTITY(1,1), PRODUCT…
SQLGuy2012
  • 51
  • 1
  • 3
3
votes
3 answers

Select row data in addition to structured XML data

I know how to join an XML variable to other tables, but in this case, I am trying to select each row from a table plus the structure of the XML from each respective table row, alongside that row. I cannot find any examples online to help with this,…
EvilDr
  • 8,943
  • 14
  • 73
  • 133
3
votes
1 answer

Microsoft SQL Server Error 18056, Login failed password did not match

We are using SQL Server 2012 Standard version. Yesterday our web-servers can't connect DB server. So I check EventLog of DB server. We got an Error: The client was unable to reuse a session with SPID 57, which had been reset for connection…
JangWei
  • 51
  • 1
  • 5
3
votes
1 answer

How to have a trigger in one DB insert data into another DB over linked server connection

I have created a linked server on SQL Server 2012. By which we can perform insert and select operations successfully, but when it comes to add a trigger on my local server table to insert data on linked server table. I get an error: No Transaction…
nimra asad
  • 179
  • 6
  • 18