Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I'm working on Bank domain I would like to deduct some amount from Table 1 and insert these values into table 2...guys can you please help Thanks in advance
Posted
Comments
[no name] 14-Apr-14 15:41pm    
http://www.w3schools.com/sql/sql_select_into.asp
Member 10735211 15-Apr-14 0:08am    
I would like to deduct amount from one table and these values insert into another table
What have you tried and where is the issue?
Member 10735211 15-Apr-14 0:07am    
I wpuld like to deduct amount from some person bank account and these amount insert into another person account
What have you tried for this?

1 solution

You can make procedure as follows.


SQL
ALTER PROCEDURE [dbo].[DeductAmountFrom1]
@Amount Decimal -- assumed amount is type of decimal
AS
BEGIN
   --scenario 1--
   --tablename == table which needs to update
   --amountcol = column which needs to update
   --filter condition == updation criteria
   --tablename2 ==  insertion required table
   --[column1,columns2] other columns name
   --insertamountcol == insertion required column name
   --[other columns value] ==other columns values

   Update tablename
   set
   amountcol= amountcol-@Amount
   where [filter condition]

   Insert into tablename2
   ([column1,columns2], insertamountcol]
   VALUES ([other columns value], @Amount);

END
 
Share this answer
 
Comments
Member 10735211 15-Apr-14 10:08am    
Thanks Ashok

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900