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.
| Author |
Topic |
|
temuri
Starting Member
8 Posts |
Posted - 2011-03-26 : 21:23:03
|
| HI! I have two tables. with almost same dataTabl1 ID,userID,username,descriptionTabl2ID,userID,username,descriptionI want to transfer description from Table1 to Table2 where userID are same and not existsplease help! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-03-27 : 01:09:51
|
| you want to insert the new description also as a new value or overwrite the existing one?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
temuri
Starting Member
8 Posts |
Posted - 2011-03-27 : 06:24:50
|
| I want to add description fromt table1 to table2 where description is null |
 |
|
|
temuri
Starting Member
8 Posts |
Posted - 2011-03-27 : 06:25:19
|
| tkizer I will try.. tank you |
 |
|
|
temuri
Starting Member
8 Posts |
Posted - 2011-03-27 : 06:43:57
|
| and also where date value where I want to compare with date(month, year) only values where month and year in date value is same.thank you |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-03-27 : 07:21:23
|
In the list of columns in your original posting, you didn't show a date column. But, if you do, you can add the new conditions to Tara's query as inquote: Originally posted by tkizer UPDATE t2SET description = t1.descriptionFROM Table2 t2JOIN Table1 t1ON t2.userID = t1.userIDWHERE t2.description IS NULLand year(t1.dateColumn) = year(t2.dateColumn)and month(t1.dateColumn) = month(t2.dateColumn)Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog
|
 |
|
|
|
|
|