Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
SQL
SqlCommand cmd = new SqlCommand(insert  into tab_bill(code,sub_code,name and amount) select <pre>code,sub_code,name and amount from tab_initial where code=66 &quot;, con);
          int q = cmd.ExecuteNonQuery();

I want to increment instalment_no by 1  from tab_initial(selected rows to insert)whenever this enter query will trigger from selected rows..
Posted

You may define the id column as IDENITY - http://msdn.microsoft.com/en-us/library/ms186775.aspx[^]
If you do so SQL will increment its value on each and every insert...
 
Share this answer
 
Comments
Maciej Los 20-Oct-14 13:11pm    
+5
Kornfeld Eliyahu Peter 20-Oct-14 13:15pm    
Thank you...
10923679 24-Oct-14 6:18am    
no... i get the solution..


for e.g


update tab_bill set instalment_no=instalment_no + 1
(select code,sub_code,name and amount from tab_initial where code=66)
Kornfeld Eliyahu Peter 25-Oct-14 13:44pm    
I hope you will not be surprised when this solution will not give you unique id...
XML
SqlCommand cmd = new SqlCommand(update tab_bill set instalment_no=instalment_no+1
select code,sub_code,name and amount from tab_initial where code=66;,con);
          int q = cmd.ExecuteNonQuery();
 
Share this answer
 

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