SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to insert values in single column with where
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ajit.Rawat3
Starting Member

India
4 Posts

Posted - 04/28/2013 :  01:56:28  Show Profile  Reply with Quote
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.

Edited by - Ajit.Rawat3 on 04/28/2013 23:24:25

khtan
In (Som, Ni, Yak)

Singapore
17650 Posts

Posted - 04/28/2013 :  02:19:55  Show Profile  Reply with Quote

update e
set    join_date = '2013-04-28'
from   empno e
where  . .  .



KH
Time is always against us

Go to Top of Page

Ajit.Rawat3
Starting Member

India
4 Posts

Posted - 04/28/2013 :  23:17:34  Show Profile  Reply with Quote
Thanks for the reply friend but I need to insert multiple values in the column with single query.

Edited by - Ajit.Rawat3 on 04/28/2013 23:19:47
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52320 Posts

Posted - 04/29/2013 :  00:21:35  Show Profile  Reply with Quote
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

India
4 Posts

Posted - 04/29/2013 :  22:50:27  Show Profile  Reply with Quote
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

India
52320 Posts

Posted - 04/30/2013 :  03:55:24  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000