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 |
|
pwvailla
Starting Member
31 Posts |
Posted - 2010-09-27 : 23:09:35
|
| table Aordernobuscodebusunitcustnameengnotable bordernobuscodebusunitcustnameengnoengstartengfinishtable cordernoprojectnoproject_nametable dprojectnoproject_statusSQL problem:Table A is used to update / insert records into table B provided the orderno exists in table c and the table D project_status = 'A' for an active project.I know you will connect the tables A + B with orderno+buscode and tables A + C with orderno and table C + D by projectno.Do you create a separate UPDATE routine and an INSERT? What would they look like with the JOINS? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-30 : 12:32:04
|
| if you're using SQL 2008 you can use MERGE. else you need separate UPDATE and INSERT. UPDATE will have INNER JOIN between A and B as its for existing records and INSERT will have LEFT JOIN and condition check b.field IS NULL to identify new records------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|