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

How to call a function in another Function

I need to write a script that creates and calls a function named fnItemTotal that calculates the total amount of an item in the OrderItems table (discount price multiplied by quantity). To do that, this function should accept one parameter for the…
Daniel Stallard
  • 69
  • 1
  • 1
  • 5
3
votes
3 answers

How to group only by month and year?

I'm rather vaguely familiar with SQL. I use SQL Server 2012. I have this table: |Id | SiteId| SiteDesc |IsNormal| DateReview |FrequencyId| |3379| 5| colon | 1 | 2016-09-10 00:00:00.000| 1 | |3381| …
Michael
  • 13,950
  • 57
  • 145
  • 288
3
votes
2 answers

Generating error full message in email when SQL agent job fail

I have 3 SQL Agent jobs that execute SSIS packages. When the job errors out, it generates an email that has 'The job failed - ' in subject and in the email has a message 'The job failed. The job was invoked by schedule schename, the last step to run…
Roger Dodger
  • 927
  • 2
  • 16
  • 37
3
votes
1 answer

How can we take sum of each row after pivot the rows to column in SQL Server

I posted my code to get the rows to column by using pivot, but I need to get the sum of each row after pivot. BEGIN SELECT @BranchName = BranchName FROM @t WHERE id = @i SELECT @columns = ( SELECT DISTINCT…
Dona Susan Issac
  • 170
  • 1
  • 17
3
votes
2 answers

How to conditionally limit results based on a single column value

I'm working in a 3rd Party DB which uses row versioning heavily. Usually this isn't an issue, but with a particular dataset it is due to the loose business rules on the front end. As you will notice, the INNER JOIN is used to get the group of rows…
S3S
  • 24,809
  • 5
  • 26
  • 45
3
votes
1 answer

Using Lead/Lag with additional exception

I have following table: Declare @YourTable table ([Event] varchar(100),[Start] DateTime,[End] DateTime, [Tag] varchar(25)) Insert Into @YourTable values ('10PIC700422.PV 10-PSV-700073A 10-PSV-700073B','9/9/16 10:44','9/9/16 10:49','Big'), …
Joe Green
  • 209
  • 2
  • 11
3
votes
1 answer

filetable_updates table in SQL Server Profiler

Recently we started monitoring the SQL Profiler to capture queries executed in server. Strangely we observed the below query executed for every single minute in Database. SELECT table_id, item_guid, oplsn_fseqno, …
Pரதீப்
  • 91,748
  • 19
  • 131
  • 172
3
votes
2 answers

How to find the consecutive number of rows with the same value, given multiple constraints in SQL?

I am using SQL Server 2012 and my data looks like this: ActivityID ActivityCode Name_of_User ActivityCode_PrevActivity isLastActivityByUserSame 1020 B1 ABE A2 0 1021 A2 …
3
votes
1 answer

Insert Dynamic & Static Data into Temp Table

I'm new to using "Insert" functions, and know enough SQL to be dangerous. I am trying to generate my own duplicated row data by using a combination of dynamic and static data. I'm using SQL Server 2012. Example of need below. Create table…
A. Reilly
  • 33
  • 4
3
votes
3 answers

Increase MS SQL transaction performance

If you're missing information, I will attach them if requested. Workspace I have a database running on a MS SQL 2012 standard edition of this kind: tables: users(id, softId (not unique), birthdate) rows: 10.5 million indexes: all three columns,…
coivip
  • 51
  • 5
3
votes
2 answers

The request for procedure 'tblMyTable' failed because 'tblMyTable' is a table object

I have an excel workbook that uploads data into a sql database. The code has been working fine for the past year. However today I am seeing the error message below. As far as I can tell nothing has changed. The request for procedure 'tblMyTable'…
mHelpMe
  • 6,336
  • 24
  • 75
  • 150
3
votes
2 answers

SSDT in Visual Studio 2015 Oracle Connection Issue

I am trying to setup SSDT so that I am able to run reports locally and edit them in Visual Studio. I have a previous report that I know works. I have installed the Oracle Developer Tools for Visual Studio 2015. I can configure the dataset and have…
3
votes
1 answer

How to use if statement with case in SQL Server 2014

This my my table INSERT INTO Paiment (PaimentDate, Champs1, Champs2, Champs3) VALUES (2013, 90, 70, 60), (2011, 20, 30, 40), (2009, 50, 0, 60), (2008, 60, 16, 60), (2007, 0, 36, 20), (2006, 30, 25, 63), (2017, 10, 70, 40), (2019, 20,…
Ilyas
  • 153
  • 1
  • 1
  • 10
3
votes
2 answers

Alter Table 'DEFAULT' not setting default values - SQL Server

I am trying to alter an existing column and adding an integer column. While adding integer column i am setting DEFAULT as 10 but default is not setting while adding the column ALTER TABLE dbo.Contacts ADD Col1 INT DEFAULT 10 I require to do…
Kannan Kandasamy
  • 13,405
  • 3
  • 25
  • 38
3
votes
1 answer

Does the following Case statement make sense?

The case statement below should be retrieving data whenever CL.TYPE = DIAG.TYPE Then DIAG.TYPE is true and if not not then NULL. Does this make sense? Or Is this the most logical way to do this? (CASE WHEN CL.TYPE2 = DIAG.TYPE OR CL.TYPE3 =…
EkansDasnakE
  • 67
  • 1
  • 10
1 2 3
99
100