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 |
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2011-04-29 : 08:32:36
|
| Hello,I have two tabletable1(projectName,subProjectName etc...)table2(ProjectID,ProjectName)Question 1.Now, I want to copy distinct data from table1(projectName) to table2(ProjectName)question 2.I want to copy data to other columnmeans in table1 if subprojectName is null then it will as ProjectNamemeans I want to copy ProjectName as SubProjectNameRegards |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-29 : 08:39:22
|
| insert table1 (projectName,subProjectName)select distinct projectName, projectNamefrom table2or maybeinsert table1 (projectName,subProjectName)select distinct projectName, projectNamefrom table2where projectName not in (select projectName from Table1)update table1 set subProjectName = ProjectNamewhere subProjectName is null==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-04-29 : 08:39:46
|
| I think you want to UPDATE table1 with values from table2? If the subprojectname in table1 is null, then update it with the projectname from table2? Do table1 and table2 link on ProjectID or ProjectName?JImEveryday I learn something that somebody else already knew |
 |
|
|
|
|
|