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

Why does the namespace definition appear on the inner element of this query as well as the outer one

Consider the following reasonably simple sql query; Declare @ad varchar(3) = 'GBR', @date varchar(10) , @time varchar(5), @refnum varchar(17), @tm varchar(2) = 'CU'; Set @date = FORMAT(GETUTCDATE(),'yyyy-MM-dd'); Set…
Dom Sinclair
  • 2,458
  • 1
  • 30
  • 47
3
votes
1 answer

SQL Server Row_Count with Reset

I have 6 columns: Date, Account, Side, Symbol, Currency, Reset Flag (0 Yes, 1 No) I want to row count over partition by but reset the row count whenever a 0 appears in Reset Flag column. The first 5 columns are not unique but their combination…
3
votes
2 answers

How to query a table with multiple values in one column with join

Table 1: A B C Test 1 This Test1 1;4 That Test2 7 What Test3 6;2 Which Test4 1;2;7 Where Table 2: X Z 1 Sun 2 Mon 3 Tue 4 Wed 5 Thu 6 Fri 7 …
Si8
  • 9,141
  • 22
  • 109
  • 221
3
votes
2 answers

How do I group sets based on column value

I found this: How to group/rank records based on a changing value of a column? which is similar to what I'm looking for but isn't quite working the way I need it to. Basically, I have data that looks like this: Id UserId Type …
ahwm
  • 672
  • 9
  • 23
3
votes
2 answers

Data normalization: switch column and rows of data

I have a table like this: Table 1 ID Data 1 Name 2 Adam 3 SEX 4 Male 5 AGE 6 27 7 Name 8 Bob 9 SEX 10 Male 11 AGE 12 28 And I'd like to convert it into following format ID NAME SEX AGE 1 Adam Male 27 2 …
X.Z
  • 1,018
  • 2
  • 11
  • 16
3
votes
2 answers

SQL query for getting conversion days between Active to inactive of employee

ID EmployeeID Status EffectiveDate 1 110545 Active 01-01-2011 2 110700 Active 05-01-2012 3 110060 Active 05-01-2012 4 110222 Active 30-06-2012 5 …
Ashvin
  • 29
  • 4
3
votes
1 answer

Group By with Min and Max Date using T-SQL

I am trying to do some SQL on the data from the SF Bay Area Bike Share Kaggel Data When I run this SQL: /****** Select Bikes ******/ SELECT count(t.[id]) as TripCount ,t.[bike_id] FROM [dbo].[trip] t Group By t.[bike_id] having count(t.[id]) <…
kiltannen
  • 1,057
  • 2
  • 12
  • 27
3
votes
1 answer

SQL date filtering

Just a fairly general date filtering question... I've got a date field that contains YYYYMMDD (no time). When looking for transactions in the current month I get a different result if I do... and MyDateField between '2017-03-01' and '2017-03-31' to…
dazzathedrummer
  • 511
  • 2
  • 10
  • 26
3
votes
3 answers

How to solve a recursive situation in SQL where back and forth going between 2 tables is needed?

I have 2 tables. GeneralContractors Partners Each GeneralContractor has its partners in partners table and each partner is associated to general contractor. Both table has IsBlackList against each record which means if I blackList a single…
Covert
  • 480
  • 1
  • 7
  • 25
3
votes
3 answers

SQL Server : Nvarchar to Varchar

I have a table with two columns, one is of type Varchar and the other in NVarchar. I want to update all the rows so VarcharField = NVarcharField. It won't let me because some of the rows contain chars that are not allowed in varchar column with the…
Itay.B
  • 3,991
  • 14
  • 61
  • 96
3
votes
2 answers

Alternative to dynamic SQL

I have a couple of stored procedures which use dynamic SQL. I'd really like to alter them so that they aren't dynamic, purely because they can be very annoying to troubleshoot and alter due to the error handling (clicking the error message doesn't…
Josh B
  • 324
  • 1
  • 3
  • 20
3
votes
1 answer

more efficiently pivot rows

I am trying to join multiple tables together. One of the tables I am trying to join has hundreds of rows per ID of data. I am trying to pivot about 100 rows for each ID into columns. The value I am trying to use isn't always in the same row. …
Hasib_Ibradzic
  • 666
  • 5
  • 23
3
votes
3 answers

Conversion of C# datetime to sql server datetime is throwing an error

In C# a DateTime property with value {27-01-2017 12.00.00 AM} is being passed in a data table to a procedure with an UTT parameter. UTT also has the same datatype datetime. I am using the generic method provided below. I cannot explicitly convert…
Anoop H.N
  • 1,244
  • 1
  • 15
  • 31
3
votes
1 answer

How to rename sql server 2012 instance name standalone server configuration

I have been searching for directions and steps to rename a named server instance of SQL Server 2012. I have a rare opportunity to rename both the computer name and instance of the SQL Server. I stepped into a situation where all of the naming…
Joe Resler
  • 101
  • 1
  • 2
  • 13
3
votes
3 answers

CONVERT issue in sqlserver with Msg 529 error

select CONVERT(datetime,value,103) from results This statement is giving me a error "Msg 529, Level 16, State 2, Line 1 Explicit conversion from data type text to datetime is not allowed." VALUE column Datatype is TEXT in the RESULTS table. How…
Oggu
  • 323
  • 1
  • 6
  • 18