Write a SQL command to insert and update only a particular field?



Write a SQL command to insert and update only a particular field?..

Answer / Vinika Choudhary

To insert a new record, use the INSERT statement with ON DUPLICATE KEY UPDATE clause. For example:nnINSERT INTO table_name (column_to_update) VALUES ('new_value') ON DUPLICATE KEY UPDATE column_to_update = 'new_value';nTo update an existing record, use the UPDATE statement with WHERE clause.nnUPDATE table_name SET column_to_update = 'new_value' WHERE condition;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

let's assume you have data that resides on sql server 6.5. You have to move it sql server 7.0. How are you going to do it? : Sql server database administration

1 Answers  


A successfully created SSIS package in SQL Server 2005 runs fine in MS BIDS and Integration Services. But gives error when run through an SQL-Job. What are the possible reasons?

2 Answers   Sapient,


Explain the xml support sql server extends?

1 Answers  


What are the steps you should follow to start sql server in single-user mode?

1 Answers  


2) Consider a Table name A which has below records ID --- 5 5 5 5 5 Consider another table B which has below records ID -- 5 5 5 5 5 5 5 5 How many rows will be returned by each of the below queries a) select * from A inner join B on A.id = b.ID b) select * from A left join B on A.id = b.ID c) select * from A right join B on A.id = b.ID

2 Answers   Synechron, TCS,


Write a SQL Query to find first Week Day of month?

2 Answers  


What is a fill factor?

1 Answers  


Difference between DELETE and TRUNCATE?

1 Answers   Atos, TCS,


What are translations and its use? : sql server analysis services, ssas

1 Answers  


How to tune a stored procedure?

6 Answers  


What the difference between UNION and UNIONALL?

1 Answers   HCL,


What are the encryption mechanisms in sql server?

1 Answers  


Categories