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 2012 Pivot Table

I need to create a query that shows the results in a pivot table. I have a table that is updated regularly with clients Build Status Changes WE have 8 stages to a build 115 Land Purchased 116 Foundations 117 Timber Kit Erected / Wall Plate…
RustyHamster
  • 359
  • 1
  • 5
  • 19
3
votes
2 answers

Query records between 2 dates

I have a page that I want to run some reports on using ColdFusion and a SQL Server database. Here is my form:
Sam Allen
  • 589
  • 4
  • 6
  • 16
3
votes
2 answers

Find Missing Records From Table A For Table B Where They Don't Exist in Table C

I have 3 tables: Customer (CustomerID) CustomerEvent (CustomerEventID, CustomerID, EventTypeID) EventType (EventTypeID) Some Customer records have some CustomerEvent records with an EventType, some Customer records have no CustomerEvent…
st0rmyc
  • 33
  • 3
3
votes
0 answers

i want to get data through fromDate & toDate on employe code

here is my stored procedure...this stored procedure showing result for fromdate and toate on employee code,an aggregate function for differentiate checkIn and checkout... it shows data for checkout time only for one date,the problem is ,I need this…
Ahsan Asim
  • 41
  • 3
3
votes
1 answer

sql calculating minutes for two dates between two times

I have a table with two DateTimes (StartDateTime, EndDateTime) and I want to calculate the minutes between the two. Now, I know to use the DATEDIFF() function to get this, but I only want to get the number of minutes that fall between two TIME(0)…
3
votes
5 answers

SQL Server: Check Upper Case or Lower Case after certain Character

I have data like 'John is my name; Ram is my name; Adam is my name'. My rule is such that every first letter that comes after ; should be capital letter. How do I select all values that satisfy the rule?
bor
  • 2,211
  • 4
  • 22
  • 37
3
votes
2 answers

Run SSIS Package after checking entries in database table

Background I would like to load data for 8 tables from Source (This gets data from some other place) to Target. I have a control table in my source that maintains entries every time a table is loaded. So before I start my SSIS package, I need to…
Venkat N
  • 31
  • 3
3
votes
2 answers

An INSERT EXEC statement cannot be nested. Dealing with error

Not duplicate. The problem here is it has different structure. and I have some restrictions of what I can change and what I can't. Here I have exact example, which other tickets don't. OPENROWSET cannot be applied either, because test1 loops through…
rakamakafo
  • 1,144
  • 5
  • 21
  • 44
3
votes
2 answers

Average Genre per Movie in Genre SQL Server 2012

Stumbled across this problem that I could not find the solution too, need some help or point me in the right direction. The tables categorize several movies into multiple genres, for example: Toy Story is in the genres; Children's, Comedy and…
CharlieE
  • 33
  • 1
  • 4
3
votes
1 answer

Compare Current Row with Previous/Next row in SQL Server

I have a table named team and it like below: I just added a row_number in the 3rd column RaidNo OutComeID RN 2 15 1 4 15 2 6 14 3 8 16 4 10 16 5 12 14 6 14 …
DineshDB
  • 5,998
  • 7
  • 33
  • 49
3
votes
5 answers

SQLServer Exception: Invalid column name

com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'IDPaciente' I am getting this exception. This is my code: String query = "INSERT INTO Paciente('IDPaciente', 'NomePaciente', 'IdadePaciente', 'LocalidadePaciente')…
Gazelle
  • 53
  • 1
  • 3
  • 11
3
votes
2 answers

Unclear which type of lock I require to avoid duplicate INSERTS on unique field

I need to check if a unique (not primary key) field is present in a table, if it isn't - insert it: ID unqiueidentifier, --PK name varchar(100), otherID int --Unique Perhaps using a conditional insert: DECLARE @OtherID int INSERT INTO TableA…
niico
  • 11,206
  • 23
  • 78
  • 161
3
votes
3 answers

Single Quote Handling in Dynamic SQL Stored Procedure

I'm using a query like this: ALTER procedure [dbo].[procedure] @Search nvarchar(100) = '' declare @LargeComplexQuery nvarchar(max) = 'select * from People where Name like ''%' + @Search + '% order by Name' exec sys.sp_executesql…
Josh B
  • 324
  • 1
  • 3
  • 20
3
votes
2 answers

How to prevent timeout in query?

SELECT C.CompanyName, B.BranchName, E.EmployerName, FE.EmployeeUniqueID, pcr.EmployerUniqueID, Case when FE.Status_id= 1 then 1 else 0 end IsUnPaid, Case when re.EmployeeUniqueID IS NULL OR…
Covert
  • 480
  • 1
  • 7
  • 25
3
votes
2 answers

Select rows in SQL where current column value doesn't match previous value

I have a table of orders. In this table, amongst other rows, I have an ID (PK), Customer ID, Shipping country, and Order date ID | CustomerId | ShippingCountry | OrderDate 1 | 111111 | DE | 2016-08-13 2 | 222222 | GB …
gfyans
  • 1,236
  • 1
  • 16
  • 21