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 |
|
markwest05
Starting Member
12 Posts |
Posted - 2007-06-15 : 17:52:21
|
| I have a table with the following columns: Rtype, Amount, Refnumber, Color:Here is what the table looks like:RD 25 1 blueAB 45 2 greenAC 25 3 purpleAD 34 4 blueAE 25 5 pinkNow lets say I would like to create new transactions for all 'RD' Rtypes, but I would like to change the Amount to lets say, 99 for all of 'RD' types, but keep the same refNumber. For example, I want to create and insert a new transaction for RD, but with the amount 99, so that the row looks like this:RD 99 1 blueWhere do I put in the query to change the Amount value? I do not wish to use the update function, because I actually want to create a new row. The query I am using, but not working is:INSERT INTO EMPLOYEES(Rtype, Amount, Refnumber, Color)SELECT Rtype, Amount, Refnumber, ColorFROM EmployeesWHERE Rtype = 'RD';Reply With Quote |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-16 : 00:26:05
|
| INSERT INTO EMPLOYEES(Rtype, Amount, Refnumber, Color)SELECT Rtype, 99, Refnumber, ColorFROM EmployeesWHERE Rtype = 'RD'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|