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

Convert human readable duration to Time Format SQL SERVER 2014

I have this data. "2mn 56s", "30s 83ms", "2h 10mn" How to convert these into time format: hh:mn:ss - "00:02:56", "00:00:30", "02:10:00"
Vince
  • 45
  • 5
3
votes
1 answer

TF400783: The Host 'Collection' cannot be started. The host is in the process of being serviced

We are trying to copy and move our prod TFS collection over to our UAT server for some testing. However when we try to start the collection we get the following error: TF400783: the host 'Collection' cannot be started. The host in the process of…
Pravin .Kadam
  • 99
  • 1
  • 7
3
votes
3 answers

Filter rows based on certain conditions

please help me out with a solution to this problem.. table is like this - Type | SubType | Flag | Value -------------------------------- 123 | A1 | Y | 101 -------------------------------- 123 | A2 | Y | …
rai01
  • 31
  • 3
3
votes
2 answers

Calculating Age of Years in SQL

I need some help with SQL Server 2012 trying to calculate an Aging Years Field for a report. Basically, I have two fields StartDateTime and EndDateTime and here is some sample data below: StartDateTime EndDateTime 2006-10-10…
smul86
  • 401
  • 1
  • 8
  • 22
3
votes
3 answers

"Must declare the scalar variable" error when executing a stored procedure

I have tried to make a procedure to insert a price: create procedure prInsertPrice @NuggetID varchar(5), @Unit_Price money, @Start_Date datetime, @End_Date datetime as begin DECLARE @date AS DATETIME SET @date = GETDATE() if ( …
3
votes
1 answer

Collate while parsing xml

On same server I have few databases with diferent collation. I'm parsing xml as CREATE TABLE #tblDocuments ( Document varchar(5) COLLATE DATABASE_DEFAULT ,DocCode varchar(15) COLLATE DATABASE_DEFAULT ,Ammount decimal(18,2) ); IF…
3
votes
1 answer

Transposing only few columns in SQL Server

I have 4 columns in my table like : key cusi isi name 1 46644UAQ1 US46642EAV83 A 1 46644UAR9 XS0062104145 A 1 254206AC9 A 2…
baiduXiu
  • 167
  • 1
  • 3
  • 15
3
votes
1 answer

Increment column value by one

I am trying to update a column (int) and it is not incrementing by 1 like I want it to, but it's incrementing by every 8 rows. So it is doing this: Table1: ID FIELD_NUMBER ---------------- 1 3507572 2 3507572 3 3507572 4 3507572 5 …
Peter Sun
  • 1,675
  • 4
  • 27
  • 50
3
votes
4 answers

SQL - Compare rows in a table to find column differences - self join

I have the following table: DECLARE @TABLE_A TABLE ( id int identity, name varchar(20), start_date datetime, end_date datetime, details nvarchar(500), copied_from int) Users can clone a row and re-insert it into the same…
03Usr
  • 3,335
  • 6
  • 37
  • 63
3
votes
1 answer

Define a relationship between two SQL Server tables (parent to child column) without the use of unique or key columns

I am trying to build a table which will hold the 'relationship' of a parent table and a child table. However each column in both tables are no keys or unique and there are duplicate values in each. Example Table A - Parent…
xblade
  • 55
  • 5
3
votes
2 answers

Group by based on two columns , eliminate data set on another column which is not in group by

What i am looking for is I have a table like this Table 1. COLUMN1 | COLUMN2 | Source --------------- --------------- 1 | X | a 1 | X | b 1 | X | c 2 | Y | a …
shanavascet
  • 589
  • 1
  • 4
  • 18
3
votes
1 answer

If I call a function inside of a SQL query, will it get evaluated on every row?

I have a series of constant functions to make programming and reading some of my SQL queries easier. For instance, dbo.CONST_DogBreed(NVARCHAR(MAX)) will return an INT for a given dog breed. E.g., dbo.CONST_DogBreed('Labrador') may return 12. The…
Nate Diamond
  • 5,525
  • 2
  • 31
  • 57
3
votes
1 answer

How to connect from Azure function app to my SQL Server?

So when some event goes to event hub it triggers Azure Function App, which should now connect to my SQL Server on virtual machine Windows Server 2012 and do some command there. My VM is online and has password, my SQL Server instance has no…
3
votes
1 answer

Rename a column in EF with Code First

i renamed a column in my class. It looked like this. public class clsClassForStackoverflow { [Column(TypeName = "varchar"), StringLength(150)] public string Name { get; set; } Because of a change in the structure i had to rename it. So i…
3
votes
2 answers

How to control the calendar system when using the Parse function?

I have the need in SQL Server to convert strings to date times that are formatted in different cultures based off of the .net DateTime type. I can do that easily for most cultures using the SQL Server parse function. SELECT PARSE(N'4/22/1996…
Aaron Carlson
  • 5,522
  • 4
  • 31
  • 35