WITH Ranked AS (
SELECT
Price_ID,
Term,
C_Kwh,
ROW_NUMBER() OVER (PARTITION BY Price_ID ORDER BY Term ASC) AS rn_asc,
ROW_NUMBER() OVER (PARTITION BY Price_ID ORDER BY Term DESC) AS rn_desc
FROM PricingTable
),
FirstLast AS (
SELECT
Price_ID,
MAX(CASE WHEN rn_asc = 1 THEN Term END) AS FirstTerm,
MAX(CASE WHEN rn_desc = 1 THEN Term END) AS LastTerm,
MAX(CASE WHEN rn_asc = 1 THEN C_Kwh END) AS First_C_Kwh,
MAX(CASE WHEN rn_desc = 1 THEN C_Kwh END) AS Last_C_Kwh
FROM Ranked
GROUP BY Price_ID
)
SELECT
Price_ID,
FirstTerm,
First_C_Kwh,
LastTerm,
Last_C_Kwh,
CASE
WHEN Last_C_Kwh > First_C_Kwh THEN '✅ Increased'
WHEN Last_C_Kwh = First_C_Kwh THEN '⚠️ Same Value'
WHEN Last_C_Kwh < First_C_Kwh THEN '❌ Decreased'
ELSE 'N/A'
END AS ComparisonResult
FROM FirstLast
ORDER BY Price_ID;
WITH Ranked AS (
SELECT
Price_ID,
Term,
C_Kwh,
ROW_NUMBER() OVER (PARTITION BY Price_ID ORDER BY Term ASC) AS rn_asc,
ROW_NUMBER() OVER (PARTITION BY Price_ID ORDER BY Term DESC) AS rn_desc
FROM PricingTable
)
SELECT
Price_ID,
Term,
C_Kwh,
CASE
WHEN rn_asc = 1 THEN 'First Term'
WHEN rn_desc = 1 THEN 'Last Term'
END AS TermPosition
FROM Ranked
WHERE rn_asc = 1 OR rn_desc = 1
ORDER BY Price_ID, Term;
SELECT
t1.Price_ID,
t1.Term,
t1.C_Kwh,
t2.C_Kwh AS Prev_C_Kwh
FROM your_table_name t1
LEFT JOIN your_table_name t2
ON t1.Price_ID = t2.Price_ID
AND t1.Term = t2.Term + 1
WHERE t2.C_Kwh IS NOT NULL
AND t1.C_Kwh < t2.C_Kwh
ORDER BY t1.Price_ID, t1.Term;
WITH OrderedData AS (
SELECT
Price_ID,
Term,
C_Kwh,
LAG(C_Kwh) OVER (PARTITIONBY Price_ID ORDERBY Term) AS Prev_C_Kwh
FROM your_table_name
)
SELECT
Price_ID,
Term,
C_Kwh,
Prev_C_Kwh
FROM OrderedData
WHERE Prev_C_Kwh ISNOTNULLAND C_Kwh < Prev_C_Kwh
ORDERBY Price_ID, Term;
Subject: Request for In-Person Meeting to Discuss Promotion Consideration
Dear [Manager’s Manager’s Name],
I hope you are doing well. I will be visiting the office on [insert date(s)] and would greatly appreciate the opportunity to meet with you in person to discuss my career progression and promotion consideration.
With over 16 years of experience in process automation, system integration, and enterprise application development, I have consistently met expectations, exceeded expectations in the past year, and taken on expanded responsibilities that delivered measurable impact in the following areas:
Enterprise Value: Delivered numerous enterprise applications end-to-end, with the New Time Tracker serving as a key example — achieving a 30x performance improvement, removing operational bottlenecks, and establishing a scalable, modernized foundation.
Leadership & Governance: Helped the team understand K2 architecture and capabilities, re-engineered applications to align with best practices, streamlined the development process, and established governance standards for K2 forms and workflows. Recently mentored an intern on K2 and SharePoint, enabling them to quickly contribute and gain hands-on experience with enterprise platforms.
Operational Excellence: Partnered with the Operations team during multiple K2 upgrades, fixed several complex issues, and currently leading the K2 and SharePoint upgrade to Subscription Edition, ensuring a smooth transition and alignment with modernization goals.
I would value your perspective on my contributions and your guidance on the path forward, including preparation for future enterprise-level responsibilities.
As you’ve highlighted the importance of two-way communication, I would like to meet in person during my upcoming office visit. I can adjust my schedule based on your availability.
Thank you very much for your time and consideration.
CREATEPROCEDURE SP_GetAvailableTasksForTimesheet
@TimeSheetIDINTASBEGIN-- Declare variables to hold the WeekStartDate and WeekEndDateDECLARE@WeekStartDateDATE;
DECLARE@WeekEndDateDATE;
DECLARE@UserName NVARCHAR(100);
-- Fetch the WeekStartDate, WeekEndDate, and UserName from the TimeSheet tableSELECT@WeekStartDate= TimeSheetStartDate,
@WeekEndDate= TimeSheetEndDate,
@UserName= EmployeeNWName
FROM
TimeSheet
WHERE
TimeSheetID =@TimeSheetID;
-- Select tasks that overlap with the given WeekStartDate and WeekEndDate-- and are not already present in the TimeEntry tableSELECTDISTINCT
T.TaskID,
T.TaskName,
T.TaskStartDate,
T.TaskEndDate,
PR.ProjectID,
P.ProjectName
FROM Task T
JOIN ProjectResource PR ON PR.ProjectID = T.ProjectID
JOIN Project P ON PR.ProjectID = P.ProjectID
WHERE PR.EmployeeNWName =@UserNameAND P.Progress ='Open'AND T.Active =1AND (
-- Check overlap between WeekStartDate-WeekEndDate and TaskStartDate-TaskEndDate@WeekStartDate<= ISNULL(T.TaskEndDate, '9999-12-31') AND@WeekEndDate>= T.TaskStartDate
AND-- Check overlap between WeekStartDate-WeekEndDate and ResourceStartDate-ResourceEndDate@WeekStartDate<= ISNULL(PR.ResourceEndDate, '9999-12-31') AND@WeekEndDate>= PR.ResourceStartDate
AND-- Check overlap between TaskStartDate-TaskEndDate and ResourceStartDate-ResourceEndDate
T.TaskStartDate <= ISNULL(PR.ResourceEndDate, '9999-12-31') AND ISNULL(T.TaskEndDate, '9999-12-31') >= PR.ResourceStartDate
)
ANDNOTEXISTS (
SELECT1FROM TimeEntry TE
WHERE TE.TaskID = T.TaskID
AND TE.TimeSheetID =@TimeSheetID
);
END;
SharePoint Server Subscription Edition (SE) supports the following versions of Windows Server:
Windows Server 2019
Windows Server 2022
Sharepoint server upgrade
SharePoint upgrades from SharePoint 2019 to SharePoint Server Subscription Edition does not support In place upgrade.
We will need Install and configure SharePoint Server Subscription Edition on the new farm
SQL Server
SharePoint Server Subscription Edition (SE) supports the following versions of SQL Server:
SQL Server 2019 (Standard or Enterprise edition)
SQL Server 2022 (Standard or Enterprise edition)
We will need to create new SQL server instance for the
SharePoint Server Subscription Edition (SE) farm and then backup and restore DBs from old to new SQL instance
If we already have SQL Server 2019 in place it will streamline the upgrade process, as it's supported by both SharePoint versions.
Updated Stored Procedure
Here is how the updated SP_GetMissingTimesheets stored procedure might look, incorporating the overlap logic:
sql
ALTERPROCEDURE [TT].[SP_GetMissingTimesheets]
ASBEGINDECLARE@TodayDATE= GETDATE();
DECLARE@WeekStartDateDATE;
DECLARE@WeekEndDateDATE;
-- Clear previous entries in the MissingTimesheets table (optional)-- DELETE FROM MissingTimesheets WHERE Created < DATEADD(WEEK, -5, GETDATE());-- Loop through the past 5 weeksDECLARE@WeekOffsetINT=1;
-- Truncate the MissingTimesheets table to clear any existing dataTRUNCATETABLE MissingTimesheets;
WHILE @WeekOffset<5BEGIN-- Calculate the start and end dates of the week using the functionSELECT@WeekStartDate= WeekStartDate, @WeekEndDate= WeekEndDate
FROM Fun_GetWeekStartEndDate(@Today, -@WeekOffset);
-- Insert missing timesheets into the permanent table, excluding records where date ranges do not overlapINSERTINTO MissingTimesheets (EmployeeEmail, WeekStartDate, WeekEndDate)
SELECTDISTINCT E.EmployeeEmail, @WeekStartDate, @WeekEndDateFROM Resource E
LEFTJOIN TimeSheet TS ON E.EmployeeNWName = TS.EmployeeNWName
AND TS.TimeSheetStartDate =@WeekStartDateAND TS.TimeSheetEndDate =@WeekEndDateWHERE (TS.TimeSheetID ISNULLOR TS.TimeSheetStatus IN ('Not Started', 'Saved', 'Returned'))
ANDEXISTS (
SELECT1FROM Task T
JOIN ProjectResource PR ON PR.ProjectID = T.ProjectID
WHERE PR.EmployeeNWName = E.EmployeeNWName
AND (
-- Check overlap between WeekStartDate-WeekEndDate and TaskStartDate-TaskEndDate
(@WeekStartDate<= ISNULL(T.TaskEndDate, '9999-12-31') AND@WeekEndDate>= T.TaskStartDate)
AND-- Check overlap between WeekStartDate-WeekEndDate and ResourceStartDate-ResourceEndDate
(@WeekStartDate<= ISNULL(PR.ResourceEndDate, '9999-12-31') AND@WeekEndDate>= PR.ResourceStartDate)
AND-- Check overlap between TaskStartDate-TaskEndDate and ResourceStartDate-ResourceEndDate
(T.TaskStartDate <= ISNULL(PR.ResourceEndDate, '9999-12-31') AND ISNULL(T.TaskEndDate, '9999-12-31') >= PR.ResourceStartDate)
)
);
SET@WeekOffset=@WeekOffset+1;
END-- Select and format the missing timesheetsSELECTROW_NUMBER() OVER (ORDERBY E.EmployeeEmail) AS MissingTimesheetID,
E.EmployeeNWName,
E.EmployeeEmail,
E.EmployeeDisplayName,
'<ul>'+ STRING_AGG('<li>'+CONVERT(VARCHAR, M.WeekStartDate, 101) +' - '+CONVERT(VARCHAR, M.WeekEndDate, 101) +'</li>', '') +'</ul>'AS MissingWeeks
FROM
MissingTimesheets M
JOIN Resource E ON M.EmployeeEmail = E.EmployeeEmail
WHERE
M.Created >= DATEADD(WEEK, -5, @Today)
GROUPBY
E.EmployeeNWName,
E.EmployeeEmail,
E.EmployeeDisplayName;
END;
Stored Procedure
sql
CREATEPROCEDURE SP_AddEmployeeToGeneralProjects
@EmployeeNWName NVARCHAR(100)
ASBEGIN-- Declare a variable to hold the ProjectIDDECLARE@ProjectIDINT;
-- Cursor to iterate through projects with Portfolio 'General'DECLARE ProjectCursor CURSORFORSELECT ProjectID
FROM Project
WHERE PortfolioID = (SELECT PortfolioID FROM Portfolio WHERE PortfolioName ='General');
OPEN ProjectCursor;
FETCH NEXT FROM ProjectCursor INTO@ProjectID;
WHILE @@FETCH_STATUS=0BEGIN-- Check if EmployeeNWName is already in the ProjectResource table for the current ProjectID
IF NOTEXISTS (
SELECT1FROM ProjectResource
WHERE ProjectID =@ProjectIDAND EmployeeNWName =@EmployeeNWName
)
BEGIN-- Insert the EmployeeNWName into the ProjectResource tableINSERTINTO ProjectResource (ProjectID, EmployeeNWName, ResourceStartDate, Active)
VALUES (@ProjectID, @EmployeeNWName, GETDATE(), 1); -- Assuming Active and StartDateENDFETCH NEXT FROM ProjectCursor INTO@ProjectID;
ENDCLOSE ProjectCursor;
DEALLOCATE ProjectCursor;
END;
Updated Stored Procedure
sql
ALTERPROCEDURE [TT].[SP_GetMissingTimesheets]
ASBEGINDECLARE@TodayDATE= GETDATE();
DECLARE@WeekStartDateDATE;
DECLARE@WeekEndDateDATE;
-- Clear previous entries in the MissingTimesheets table (optional)-- DELETE FROM MissingTimesheets WHERE Created < DATEADD(WEEK, -5, GETDATE());-- Loop through the past 5 weeksDECLARE@WeekOffsetINT=1;
-- Truncate the MissingTimesheets table to clear any existing dataTRUNCATETABLE MissingTimesheets;
WHILE @WeekOffset<5BEGIN-- Calculate the start and end dates of the week using the functionSELECT@WeekStartDate= WeekStartDate, @WeekEndDate= WeekEndDate
FROM Fun_GetWeekStartEndDate(@Today, -@WeekOffset);
-- Insert missing timesheets into the permanent tableINSERTINTO MissingTimesheets (EmployeeEmail, WeekStartDate, WeekEndDate)
SELECT E.EmployeeEmail, @WeekStartDate, @WeekEndDateFROM Resource E
LEFTJOIN TimeSheet TS
ON E.EmployeeNWName = TS.EmployeeNWName
AND TS.TimeSheetStartDate =@WeekStartDateAND TS.TimeSheetEndDate =@WeekEndDateWHERE TS.TimeSheetID ISNULLOR TS.TimeSheetStatus IN ('Not Started', 'Saved', 'Returned');
SET@WeekOffset=@WeekOffset+1;
END-- Select and format the missing timesheetsSELECTROW_NUMBER() OVER (ORDERBY EmployeeEmail) AS MissingTimesheetID,
E.EmployeeNWName,
E.EmployeeEmail,
E.EmployeeDisplayName,
'<ul>'+ STRING_AGG('<li>'+CONVERT(VARCHAR, M.WeekStartDate, 101) +' - '+CONVERT(VARCHAR, M.WeekEndDate, 101) +'</li>', '') +'</ul>'AS MissingWeeks
FROM
MissingTimesheets M
JOIN Resource E ON M.EmployeeEmail = E.EmployeeEmail
WHERE
M.Created >= DATEADD(WEEK, -5, @Today)
GROUPBY
E.EmployeeNWName,
E.EmployeeEmail,
E.EmployeeDisplayName;
END;
sql
CREATEPROCEDURE SP_FindMissingTimesheets
ASBEGINDECLARE@TodayDATE= GETDATE();
DECLARE@WeekStartDateDATE;
DECLARE@WeekEndDateDATE;
-- Clear previous entries in the MissingTimesheets table (optional)-- DELETE FROM MissingTimesheets WHERE Created < DATEADD(WEEK, -5, GETDATE());-- Loop through the past 5 weeksDECLARE@WeekOffsetINT=0;
WHILE @WeekOffset<5BEGIN-- Calculate the start and end dates of the week using the functionSELECT@WeekStartDate= WeekStartDate, @WeekEndDate= WeekEndDate
FROM dbo.Fun_GetWeekStartEndDate(@Today, -@WeekOffset);
-- Insert missing timesheets into the permanent tableINSERTINTO MissingTimesheets (EmployeeEmail, WeekStartDate, WeekEndDate)
SELECT E.EmployeeEmail, @WeekStartDate, @WeekEndDateFROM Resource E
LEFTJOIN TimeSheet TS
ON E.EmployeeNWName = TS.EmployeeNWName
AND TS.TimeSheetStartDate =@WeekStartDateAND TS.TimeSheetEndDate =@WeekEndDateWHERE TS.TimeSheetID ISNULLOR TS.Status IN ('Not Started', 'Saved');
SET@WeekOffset=@WeekOffset+1;
END-- Select and format the missing timesheetsSELECTROW_NUMBER() OVER (ORDERBY EmployeeEmail) AS ID,
EmployeeEmail,
'<ul>'+ STRING_AGG('<li>'+CONVERT(VARCHAR, WeekStartDate, 101) +' - '+CONVERT(VARCHAR, WeekEndDate, 101) +'</li>', '') +'</ul>'AS MissingWeeks
FROM
MissingTimesheets
WHERE
Created >= DATEADD(WEEK, -5, @Today)
GROUPBY
EmployeeEmail;
END;
K2 workflow instances bloats the database over the time period and at some point you would want to delete the old workflow instance which are completed or in error status.
Unfortunately, there is no way to delete specific instances of workflow, in other words, you could not select specific instance and delete them. However, you can delete then in a bulk.
For instance, you would want to delete old workflow instances, which are completed and occupying the significant space in database. Instances where you are not going to report anything. Or, you just want to delete then as a part of clean up activity.
You can follow below steps to do so.
If you have 4.7 vision installed you can go to management workspace. For older version, you can follow similar steps
Expand workflow server node.
Go to your category to find workflow for which you want to delete workflow instances.
Click on versions.
Select version you want to delete.
6. Check “Delete all historical (log) data for selected versions”
Be careful though, “Delete all historical (log) data for selected versions” option deletes all workflow instances including active as well. Basically, it wipes out all the instances for that version from k2 database.
I asked the question to k2 support, What is the difference between Create and generate smartobject? and they provided below answer, thought would be helpful to share.
There are three different options available to create/manage SmartObject from a SQL Service Instance via SmartObject Service Tester tool:
a. From service instance > Create SmartObjects
- manages the creation and updates of all SQL SmartObjects of the service instance as well as SmartObject's category as a set (no control over displayname and guid)
- allows for the appending of a string to all of the SmartObject system name (no control over the overall displayname, systemname, guid)
- can be used to update all SmartObject as a set if there are changes to the database objects schema(tables, views, sprocs)
- displayname, systemname and guid will remain the same (if targeting the same set of SmartObject)
b. From service instance > Generate SmartObjects
- manages the creation and updates of all SQL SmartObjects of the service instance as a set (no control over displayname, systemname, category, guid)
- can be used to update all SmartObject as a set if there are changes to the database objects schema (tables, views, sprocs)
- displayname, systemname and guid will remain the same
c. From Service Object > Create SmartObject (singular)
- allows for managing of the SystemName/DisplayName, GUID, and category SmartObject is created in
- can be used to regenerate/update the existing SmartObject by targeting the 'SystemName' of the SmartObject (with the 'Check Name' button) and returning the current GUID for this SmartObject (with the 'Get Existing Guid' button) before publishing it again
** if not returning the existing name and GUID, a new SmartObject with different value will be created
* all three options mainly used if there are NO customization with the SmartObject and the default generated functionality is desired; as regenerating the SmartObject with the same SystemName and GUID will remove any customization previously done; if SmartObject was customized, manually changes to these objects in the designer that they were designed in (K2 Designer, K2 Studio, K2 for Visual Studio) will preserve the customization.
How do you fix the process in errors?
1. Sometimes the error is because of network issues, some connection problem or no proper inputs. If you just go to the error profile in the workspace and retry the error it fixes the problem.
2. If above approach does not resolve the error you can use the K2 Process Management tool in Visual Studio.
As shown in the figure below. you can select process clicking View->K2 Process Management tool in visual studio. Select the process in error and open the process and fix the error.
After fixing the error, go back to the k2 process management and click redeploy the process.
You can provide the label and deploy the process. It will fix that instance of the process. Then you can fix the processes with similar error hitting the retry button and selecting the fixed version of the process.