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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Creating new transaction query

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 blue
AB 45 2 green
AC 25 3 purple
AD 34 4 blue
AE 25 5 pink

Now 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 blue

Where 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, Color
FROM Employees
WHERE 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, Color
FROM Employees
WHERE Rtype = 'RD'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -