i need to insert records from table1 to table 2
out of 15 columns from table1 i need to insert 6 columns to table 2
if i use
insert into table2
select col1,col4,col5,col8,col10, @sqno from table1 where custid=11
if table1 has 30 records all will be inserted at once
but i need to have a loop such that
row1 will, be inserted , than 2 and so on till 30
if its possible to do without cursor it will be more good
Can you explain why you would want to do that? Presumably something to do with @sqno? Most people on this forum would feel dirty writing such a thing :-)
But if RBAR processing is really
what you want, a CURSOR is as good a way as any.
Your INSERT syntax is deficient though - you should list the columns you are inserting into:
where custid = 11
Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this
If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.
Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.