Questions tagged [sql-server-2014]
Use this tag for questions specific to the 2014 version of Microsoft's SQL Server database engine. SQL Server 2014 is the predecessor of the later SQL Server 2016.
4,742
questions
0
votes
4
answers
84
views
Get total minutes between 2 date time
I need to get a total minutes between 2 date time with the requirement where the time fall to another date should not count the minutes for the StartDate. Eg data as below
ID Start ...
1
vote
1
answer
53
views
Connect together different values with splitter that have been grouped by [duplicate]
In picture result is what result of that UNION ALL inner select looks like.
I'm having troubles connecting together values assigned to same ID.
In inner select I can get multiple same ID results, but ...
0
votes
1
answer
34
views
Question on SQL GROUPBY and find grouped data from single table based on Single value
We need table2 as output based on table1.
Here i have uploded the image and in that table1 is main table and table2 is actual output which we have to find
IMAGE
I am using MSSQL Server 2014 and i have ...
0
votes
0
answers
59
views
The incoming TDS protocol stream is incorrect' error requiring IIS restart
I'm working on an ASP.NET Core 2.0.8 application, and it has been running smoothly. However, I'm facing an intermittent issue with all of my APIs. Occasionally, when I call this API, it returns an ...
0
votes
1
answer
43
views
How to get sum of amount from multiple tables?
I have three (3) tables which l want to get the sum total of amount from it.
OrderDetail
Product
Amount
OrderDate
Apple
10
2023-09-01
Orange
5
2023-10-01
LearnerDetail
Name
Amount
OrderDate
...
0
votes
2
answers
47
views
Pivoting/Unpivoting multiple columns using dynamic SQL
I have the below requirement.
CREATE TABLE #TempData
(
Columnname1 NVARCHAR(50),
Value1 NVARCHAR(50),
Columnname2 NVARCHAR(50),
Value2 NVARCHAR(50),
Columnname3 NVARCHAR(50),
...
0
votes
0
answers
42
views
Calculate Weekly totals and should appear immediately after the corresponding week's data
I have a data like below
contact_date
count
values
06/01/2023
230
0
06/02/2023
100
0
06/03/2023
200
0
06/04/2023
250
0
06/05/2023
120
0
06/06/2023
120
0
06/07/2023
200
0
06/08/2023
2230
0
06/...
0
votes
1
answer
79
views
Count rows by monthend - year to date falling between two dates
I'm trying to create a query that can return counts of rows that fall between two dates as of the last day of the month prior and a count for the current month (MTD) at the time the query is run. For ...
0
votes
0
answers
27
views
Error when using external dll .net framework in the reporting service 2014 report
I have a project developed in C# in Visual Studio 2008, NET Framework 3.5, SQL Server 2008 Standard with Reporting Service
I migrated to Visual Studio 2019, changed the target framework of all ...
1
vote
3
answers
45
views
How to optimise a query with multiple subqueries for string aggregation?
This is my query:
SELECT
wp.WorkplanID,
STUFF((SELECT ', ' + ISNULL(ul.FirstName + ' ', '') + ISNULL(ul.LastName, '')
FROM UserLogin ul
INNER JOIN Vendors v ON ul....
1
vote
1
answer
42
views
Group by MIN value in SQL Server pivot table query
I have looked through some similar questions but still can't figure this out.
My query:
SELECT *
FROM
(SELECT
Sites.ID AS SiteID,
MIN(DateInspectionDue) AS DateDue,
...
-4
votes
3
answers
82
views
Update column with leading zeros
Hope someone can help. I am trying to pad a zero infront of any result that has under 10 digits in column GPF4.
The column GPF4 is designed to be Numeric(18,0) as later on I will be converting this ...
0
votes
1
answer
66
views
Join most recent event into daily splits
I currently have a table of events with a time stamp and a "state" description of that event. The distribution of these events are rather random--I may have a hundred events in a day, ...
-4
votes
1
answer
58
views
In SQL how to take rows of data and collate into a new row
I have a table in SQL Server 2014 which stores all the process steps users have done on handheld scanners. The use of the scanners is to pick stock for sales orders.
The table has the following ...
0
votes
0
answers
15
views
[email protected] not working with SQL Server 2014
I'm currently using the mssql package version 4.3.0 in my Node.js project to connect to a SQL Server 2014 database. However, I'm experiencing difficulties establishing a connection. Here are the ...
1
vote
0
answers
38
views
SSRS fails to connect SQL Server DB Hidden instance
We had to set SQL Server hide instance flag as "Yes" in production to fix the violation like ADHOCdistQueries_RunValue, hideinstance etc.
But once we hide the instance, SSRS data source ...
0
votes
1
answer
35
views
How to setup to run a query against 2 databases
I am trying to find out which staff records are in the Production system and not in development with this query: If the id_number is not in the dev system then we need to update. They both have ...
0
votes
0
answers
119
views
SQL Server Always-on AG: database property TRUSTWORTHY on secondary replica different from primary replica
In an environment with SQL Server 2014 (there are practically even this version still in use), I routinely checked for databases that had the TRUSTWORTHY property enabled.
I stumbled across a database ...
0
votes
0
answers
51
views
SSRS report returning error at XML position that is higher than max position in the file
I have a report in SSRS that is not playing nicely on a single installation instance. All other installations the report runs as expected. All other reports on the offending server run as expected as ...
1
vote
1
answer
34
views
How to get all records from previous year
My code is producing current year's rows instead of previous year's rows in the last year column
DECLARE @prevYear int
DECLARE @prevMonth int
SELECT @prevYear = DATEPART(year, GETDATE() - 1)
SELECT @...
0
votes
0
answers
21
views
How to formulate IRR(excel formula - 1+IRR(F10:F22)^12-1) in SQL Server
How to formulate IRR(excel formula - 1+IRR(F10:F22)^12-1) in SQL Server
What I need to add is IRR based on M0 to M60 columns.
Expected Result :
IRR = 24.24%
I've tried several code but it's not ...
1
vote
0
answers
38
views
User types get "strange" names in sys_objects? [duplicate]
I've never used a user type in SQLS before, and I've been handed some sql code that creates one. Unfortunately the code assumes it doesn't exist, so I added a IF...DROP. But that does not happen...
IF ...
0
votes
1
answer
61
views
Calculate the percentage of a column base on year
I want to get the percentage of column Quantity based on the same year.
ID
Model
Year
Qty
1
M1
2020-01-01
10
2
M2
2020-02-07
12
3
M3
2020-11-20
7
4
M1
2021-01-04
8
5
M2
2021-05-19
5
6
M3
2021-...
0
votes
1
answer
62
views
SQL Server using IIF in Where Clause Syntax Error
I'm using SQL Server 2014. I keep getting a red squiggly lines under the last = sign and last parenthesis:
DECLARE @I_sYear char(4);
SET @I_sYear = '2021'
SELECT
PriceType,
SUM(PriceAmount) ...
0
votes
0
answers
46
views
DISTINCT results of CTE Outer Apply return empty set
Summary:
Results of CTE using OUTER APPLY return duplicates due to dirty nature of data and results of RegexFind to split out commingled key=value pairs.
When using DISTINCT on that CTE, the result is ...
0
votes
0
answers
62
views
Running SQL Server SSIS Package from Data Tools and its SQL Job produce different results; same package version, nothing changed
This one has me snake bit and I don't say that often. FTR, I'm running SQL Server 2014 and SQL Server Data Tools for Visual Studio 2013 aka SSDT.
I have a SSIS package that was deployed via ...
0
votes
0
answers
56
views
SQL Full Backup Timeout
I've to do a backup on SQL2014 of a database of size 400GB.
When I do a the backup after 15min SQL give me an error : Time out. The available time expired before the operation was completed or the ...
1
vote
1
answer
152
views
What Roles and/or Permissions would I need to Assign to Users
I would like to have certain users of an Sql Server database to be able to:
Create Logins
Create Users in databases
Assign insert, update, select and delete permissions on certain tables within that ...
0
votes
2
answers
180
views
How to Get Latest Updated TABLES in SQL?
I use Microsoft SQL Server to maintain the data which received from other software (Smartplant Instrumentation). I want to know the last table which was updated and inserted by the data from the other ...
1
vote
1
answer
693
views
Hibernate "Invalid object name 'TABLENAME_SEQ'. " when inserting
I am writing a spring-boot application with hibernate. The application connects to a MSSQL 2014 database. I have used this tutorial for the basic architecture:
https://www.baeldung.com/spring-boot-...
0
votes
0
answers
361
views
SSIS script task used to send emails
I've used a script task in SSIS 2014 in C# works very well until it raises an error then stops. I want to record the error and continue. I've set to false the properties FailPackageOnFailure and ...
0
votes
0
answers
20
views
SQL Server 2014 views differences in code
when I see the code in the view designer it's different from the code showed when I script the view using "ALTER TO" new query editor. Just an example
In design mode:
SELECT * FROM products ...
0
votes
2
answers
98
views
Dynamically add columns to query results
I am looking for a query to summarized data representing manufacturing job operations in one line. For example, a job can have multiple operations and not all jobs have the same operations. Then ...
0
votes
0
answers
149
views
How to define filegroup for SQL server in AWS?
I've been tasked to move on-prem SQL Server database to AWS RDS SQL Server and from there migrate the data to postgresql.
I'm preparing for those and in the DB creation script found the term "...
0
votes
0
answers
128
views
Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap on ASP.NET WEB API
I am trying to build an ASP.NET Web API application that will run dtsx files expected to be on the same server, but I am getting error below:
System.IO.FileNotFoundException: Could not load file or ...
1
vote
0
answers
69
views
Database email job succeed but no email with attachment received
I have set a databasemail profile on SQL2014, created a job, run it and the job succeed but I don't receive any email with my attachment.
Here is my query:
declare @clientname as varchar(50)
set @...
0
votes
1
answer
57
views
SQL rebuild Index Maintenance Plan is missing the Index Stat Option to set fragmentation percentages?
My maintenance plan is missing the section in the config window that allows you to set the fragmentation > a percentage. Does anyone know how to get this option or is it maybe I'm on too old a ...
0
votes
0
answers
49
views
Extract firstname and lastname, but firstname max length
I need to get the first and last name, but the maximum in the first name is 30 characters
declare @name nvarchar(250)='David Judith and Holofernes Equestrian of Gattamelata'
SELECT LEFT(rtrim(@name), ...
0
votes
0
answers
76
views
SQL Server 2014 : Merge replication and transactional on same database
We currently have merge replication setup between Server 1 and Server 2. Server 2 is in a different geographic location. The merge replication is there so that users in the same region as Server 2 hit ...
-1
votes
2
answers
49
views
Passing variable precision to TIMEFROMPARTS function
I'm trying to build a function that takes a string as input representing a time variable with no separators. The fraction part could have variable precision.
This is the code I came up with :
CREATE ...
1
vote
1
answer
372
views
SQL Query Dynamically get columns depending on mapping
I am stuck on an issue. I am trying to create a select which returns information depending on the Rules Mapping table. The Rules table tells us where (TableName.ColumnName) value should come from. I ...
0
votes
1
answer
285
views
Convert DateTimeOffset to DateTime in a where between 23:00 previous day an 07:00 Am next day for past 2 weeks
I have to make an query on a table where the datetime field is of type datetimeoffset.
The query itself is already difficult, but now working with conversions makes it even more complicated. What I ...
0
votes
0
answers
68
views
Use an Excel Cell as a Input Data for filtration to a SQL Server View
I have a basic view in SQL Server which includes these columns,
"Lot Number" , "Time" , "Code" , "Name" , "Barcode"
Now I need a Excel file which will ...
0
votes
2
answers
51
views
SQL to pull only the first 10 records of all fields in table, grouped by only 2 columns
My SQL skills are too weak to solve this problem, but I am pretty certain it is possible to solve.
To simplify - I have a small table with 5 columns, let's label them A, B, C, D, E. It's 1000 rows.
I ...
0
votes
2
answers
928
views
SQL remove characters from string and leave number only
I have string(nvarchar) from db data and I would like to transfer it to numbers only. I was searching on Google for solution but I didnt find anything. I found something similiar here on StackOverflow ...
0
votes
1
answer
334
views
Using a WITH clause inside SELECT * INTO [closed]
I have the following SQL for which I want to backup the results in to a new table (using SELECT * INTO backup_table)...
WITH LIST AS
(SELECT column1
FROM table1
UNION
SELECT column1
FROM table2
...
-2
votes
3
answers
350
views
Create a pseudo column to display Yes/No if one column value is present in another for a particular id
I have a table with the following structure :
create table test_18Nov ( account_id nvarchar(12)
, account_name nvarchar(25)
, zip_legacy_file nvarchar(5)...
0
votes
1
answer
41
views
I can't delete empty containers in an xml document on SQL Server, such as "<Item />"
I started working for the first time and I don't know much yet, I've been suffering with this problem for two days.
I have a document of this type:
<Tables>
<dbo.ES_Connection_Modes>
...
0
votes
0
answers
54
views
How can I manually release a updlock on a table
What I want to do :
begin tran
update table_x updlock
set x = y
where z = a
exec process_stuff @input_parameters
--here i want to release the updlock so it becomes available for other ...
0
votes
0
answers
88
views
Why is the SSRS Barcode breaks up with a space in between?
I have a SSRS report which I've initially created with SQL Server 2014 Report Builder (12.0.6024.0) using Code128 according to this post. It has been working great until we wanted to upgrade our SQL ...