Introduction
This blog will help users update a record while keeping the existing record value if it exists. My initial requirement was to just update the record but after some time, there was a case in my project to update the same record from two different pages.
So, in this case, I rneeded to append a query. Please check the below query to append a record.
I have given a summary of the below three approaches to append an existing record.
This blog will help users update a record while keeping the existing record value if it exists. My initial requirement was to just update the record but after some time, there was a case in my project to update the same record from two different pages.
So, in this case, I rneeded to append a query. Please check the below query to append a record.
I have given a summary of the below three approaches to append an existing record.
- Check if their existing value is not present; then, do not append the record, just update it.
- If the value exists, then append the new value with comma separation.
- Update salary will do the sum of another salary with existing salary.
Create Table
I have created an ‘Employee’ table design which is given below.
- CREATE TABLE[dbo].[Employee](
- [EMPLOYEE_ID][bigint] NOT NULL, [FIRST_NAME][varchar](50) NOT NULL, [LAST_NAME][varchar](50) NOT NULL, [SALARY][bigint] NOT NULL, [JOINING_DATE][datetime] NOT NULL, [DEPARTMENT][varchar](50) NOT NULL) ON[PRIMARY]

Insert Record into table
- INSERT INTO Employee VALUES (1,'Sagar', 'Shinde', 25000, 2017-02-01,'Developer');
- INSERT INTO Employee VALUES (2,'Swapnil', 'Shinde', 30000, 2016-02-01,'Doctor');
- INSERT INTO Employee VALUES (3,'Pankaj', 'Shinde', 30000, 1000-02-01,'');


Hadshana KamalanathanPosted Jul 16, 2018, 8:14 PM
Thank you for sharing