How To Perform Insert Update Delete 10000 Rows A Time Data In Sql Server Using Merge Statemnt
SQL | UPDATE Statement
The UPDATE statement in SQL is used to update the data of an existing tabular array in database. Nosotros can update unmarried columns as well as multiple columns using UPDATE statement as per our requirement.
Basic Syntax
UPDATE table_name Set up column1 = value1, column2 = value2,... WHERE condition; table_name: name of the tabular array column1: name of first , second, third column.... value1: new value for showtime, second, third cavalcade.... condition: condition to select the rows for which the values of columns needs to exist updated.
NOTE: In the above query the SET argument is used to set new values to the particular column and the WHERE clause is used to select the rows for which the columns are needed to exist updated. If we have not used the WHERE clause then the columns in all the rows will be updated. And then the WHERE clause is used to cull the particular rows.
Example Queries
- Updating single column: Update the column Proper name and set up the value to 'PRATIK' in all the rows where Age is 20.
UPDATE Educatee Fix NAME = 'PRATIK' WHERE Age = xx;
Output:
This query will update ii rows(tertiary row and fifth row) and the tabular array Student will now look like,ROLL_NO Proper name ADDRESS PHONE Historic period 1 Ram Delhi XXXXXXXXXX 18 2 RAMESH GURGAON XXXXXXXXXX 18 3 PRATIK ROHTAK XXXXXXXXXX twenty 4 SURESH Delhi XXXXXXXXXX 18 three PRATIK ROHTAK XXXXXXXXXX 20 ii RAMESH GURGAON XXXXXXXXXX 18
- Updating multiple columns: Update the columns Name to 'PRATIK' and Accost to 'SIKKIM' where ROLL_NO is 1.
UPDATE Pupil SET NAME = 'PRATIK', Address = 'SIKKIM' WHERE ROLL_NO = one;
Output:
The above query will update 2 columns in the first row and the tabular array Educatee will now look like,ROLL_NO NAME Address Telephone Age 1 PRATIK SIKKIM XXXXXXXXXX 18 2 RAMESH GURGAON XXXXXXXXXX eighteen 3 PRATIK ROHTAK XXXXXXXXXX xx 4 SURESH Delhi XXXXXXXXXX 18 3 PRATIK ROHTAK XXXXXXXXXX twenty 2 RAMESH GURGAON XXXXXXXXXX 18 Note: For updating multiple columns we accept used comma(,) to separate the names and values of 2 columns.
- Omitting WHERE clause: If nosotros omit the WHERE clause from the update query then all of the rows will get updated.
UPDATE Student SET NAME = 'PRATIK';
Output:
The tabular array Student volition now wait similar,ROLL_NO NAME ADDRESS PHONE Age 1 PRATIK Delhi XXXXXXXXXX eighteen 2 PRATIK GURGAON XXXXXXXXXX 18 iii PRATIK ROHTAK XXXXXXXXXX 20 4 PRATIK Delhi XXXXXXXXXX 18 iii PRATIK ROHTAK XXXXXXXXXX 20 2 PRATIK GURGAON XXXXXXXXXX xviii
This commodity is contributed by Harsh Agarwal. If y'all like GeeksforGeeks and would like to contribute, you tin can as well write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. Meet your article actualization on the GeeksforGeeks primary page and help other Geeks.
Please write comments if yous find annihilation incorrect, or you want to share more information near the topic discussed above.
Source: https://www.geeksforgeeks.org/sql-update-statement/
Posted by: bellomyparang.blogspot.com
0 Response to "How To Perform Insert Update Delete 10000 Rows A Time Data In Sql Server Using Merge Statemnt"
Post a Comment