Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to insert values in single column with where

Author  Topic 

Ajit.Rawat3
Starting Member

4 Posts

Posted - 2013-04-28 : 01:56:28
How to update values in single column with where conditions.

For example:
table emp: with columns name:
ID, ename, join_date
1 Abhijeet
2 Baljeet
3 Charanjeet
I want to insert/update values in 'join_date' column for all the three rows in single query.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-04-28 : 02:19:55
[code]
update e
set join_date = '2013-04-28'
from empno e
where . . .
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Ajit.Rawat3
Starting Member

4 Posts

Posted - 2013-04-28 : 23:17:34
Thanks for the reply friend but I need to insert multiple values in the column with single query.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-29 : 00:21:35
quote:
Originally posted by Ajit.Rawat3

Thanks for the reply friend but I need to insert multiple values in the column with single query.


multiple values? SO what should be values you need to insert? the field says join_date so we would have expected it to contain single value which will correspond to joining date of employee

or do you mean you need different values in the field for different rows? if yes, explain where you'll get those values from

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Ajit.Rawat3
Starting Member

4 Posts

Posted - 2013-04-29 : 22:50:27
let take join_date is an empty column and I want to insert/update value for each cell of that column, how can I do it in one go (in a single query)

hope my question is clear to you. and thanks for looking into it
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-30 : 03:55:24
you can use an update as suggested but question is where will you get list of values that needs to be updated

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -