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
18
votes
4 answers

How to select rows, and nearby rows

SQL Fiddle Background I have a table of values that some need attention: | ID | AddedDate | |---------|-------------| | 1 | 2010-04-01 | | 2 | 2010-04-01 | | 3 | 2010-04-02 | | 4 | 2010-04-02 | | 5 | NULL …
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
18
votes
1 answer

How to view schema of Microsoft SQL Server?

I need a schema of Microsoft SQL Server like in this screenshot: I created a schema according to Create Schema in SSMS , but I can not view it in Microsoft SQL Server Management Studio. Databases -> [YourDatabase] -> Security -> Schemas ->…
cat
  • 253
  • 2
  • 3
  • 13
18
votes
5 answers

How to make calculation on time intervals?

I have a problem ,i solve it but i have written a long procedure and i can't be sure that it covers all the possible cases . The problem: If i have a main interval time (From A to B), and secondary interval times (Many or no) (`From X to Y AND From…
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
18
votes
5 answers

SQL Server - An expression of non-boolean type specified in a context where a condition is expected, near 'RETURN'

Getting this error with the following query in SQL Server 2012. An expression of non-boolean type specified in a context where a condition is expected, near 'RETURN'. CREATE FUNCTION [dbo].[GetPMResources](@UserResourceNo nvarchar(250)) RETURNS…
Sohail xIN3N
  • 2,951
  • 2
  • 30
  • 29
18
votes
2 answers

How to check current pool size of SQL Server

Is there a way to check the current connection pool size in SQL Server? I am not talking about the max connection pool size, but the current pool size. Let's say the max pool size is 100 and there are 49 connections open, it should now show me…
Frank Martin
  • 3,147
  • 16
  • 52
  • 73
18
votes
3 answers

How to deploy a existing SSIS Package in sql server 2012?

I am working on SSIS Package .I added one more data flow task to existing ssis package.After complition of adding new task i rebuilded the Package it was suceed with out any errors . Do i need to deploy it to Development server?
user3203331
  • 429
  • 2
  • 7
  • 23
18
votes
2 answers

Wait on the Database Engine recovery handle failed!! SQL Server 2012 installation

Can someone please guide me on how to overcome the following error. I am trying to install SQL Server 2012 Express on my win7 32bit system. I had SQL Server 2008 R2 32 bit installed in this system, which was removed by the previous user (this is an…
Youbaraj Sharma
  • 1,295
  • 3
  • 17
  • 34
18
votes
4 answers

Passing parameter of type 'object' in table-valued parameter for sql_variant column

I have a table-valued parameter in SQL Server 2012 defined as: CREATE TYPE [dbo].[TVP] AS TABLE ( [Id] [int] NOT NULL, [FieldName] [nvarchar](100) NOT NULL, [Value] [sql_variant] NOT NULL ) I call it in C# with code that looks roughly…
18
votes
5 answers

Is there an overview of all SQL Server 2012 error codes?

SQLGetDiagRec returns a native error code. Is there anywhere an overview of the error codes of SQL Server 2012? I couldn't find anything on MSDN.
Antineutrino
  • 1,093
  • 3
  • 10
  • 26
17
votes
2 answers

Query to display spent credits from transactional table

I am working with a table that contains credit transactions where I want to display who's credits were spent when a sale is made. In the table: Credits are added by an entity using a unique entity code (recorded in column GivenByUserCode) Credit…
Igor
  • 60,821
  • 10
  • 100
  • 175
17
votes
3 answers

Get difference between two times for SQL Server 2012

The background: I am trying to identify the length of time a Customer spends in a particular room. Each Customer is identifiable by a CustomerID, and when they visit they are assigned a VisitNumber. For example, if the customer visited today they…
richinsql
  • 232
  • 2
  • 8
17
votes
3 answers

How to check blocking queries in SQL Server

I have one warehouse server which got data/sync from legacy system 24/7, I noticed some of my reports/sql jobs performance is uncertain and most of the time I heard from DBA team that my query is blocking to other sync process. From DBA team I came…
17
votes
2 answers

How to unlock table in SQL Server 2012?

I created table in SQL Server 2012 and when I execute select * from tableName it is taking a long time and some time returns no result. Currently it has only 1 row. After searching I know it is being locked so please help how to unlock it or drop…
Pushkar Jaju
  • 569
  • 1
  • 4
  • 11
17
votes
16 answers

Get All Dates of Given Month and Year in SQL Server

I want to get all dates by declaring month and year in SQL server. Can anyone please share easy lines of SQL code to get it. For example: DECLARE @month AS INT = 5 DECLARE @Year AS INT = 2016 SELECT * from Something I have tried below…
Pedram
  • 6,256
  • 10
  • 65
  • 87
17
votes
4 answers

Select all parents or children in same table relation SQL Server

SQL developers, I have a badly planned database as task to learn a lot about SQL Server 2012. SO, there is the table…
Khronos
  • 195
  • 1
  • 1
  • 8