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 |
|
vwilsonjr
Starting Member
45 Posts |
Posted - 2002-11-25 : 13:15:15
|
| I have a table that I imported into a database (from a text file). I want to update another table with the information in the new table. The logic behind it is simple but has me stumped.if (newtable.employeeID) = (usertable.employeeID) update recordelse insert recordI'm stumped in the if statement. Any help would be great. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-11-25 : 13:19:09
|
| just do it in two statements (in a transaction?)update tblset fld = fldfrom newtblwhere tbl.id = newtbl.idinsert tblselect * from newtblwhere not exists (select * from tbl where tbl.id = newtbl.id)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
vwilsonjr
Starting Member
45 Posts |
Posted - 2002-11-25 : 14:21:18
|
| What does "set fld = fld" do? |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-11-26 : 03:46:38
|
quote: What does "set fld = fld" do?
Set fld = fld would set fld equal to itself (IE not change the value)That is the part of the statement that you need to change to whatever you want to update. As in set fieldiwanttochange = 1orset usertable.name = newtable.name-------Moo.Edited by - mr_mist on 11/26/2002 04:04:34 |
 |
|
|
|
|
|