Insert into Select From Where (Selecting Last Same Row Data to Insert into the Same Table) - sql-server-2008

I'm trying to insert rows using the same last values of rows in the column name bill period.
this is my desired result, and after the billperiod 3 it goes into 4 taking the data rows of billperiod 3.
I tried other solution where I used the other table to use it as a where but this are the results.
but It didn't work, here is the image of my other table

Related

how many selected rows at maximum can be inserted in a table in mysql in one insert statement?

I am using this statement to copy the data of one table to another where both these tables are identical,
INSERT INTO summary_table SELECT * FROM wallet_transaction WHERE type_id = 1;
the number of rows selected from 'wallet_transaction' could be in lakhs someday, I want to know whether this query can be successful in doing this and is there any limit of rows that can be inserted after selection ?

Trying to copy or somehow move the contents (values) in a TEXT column 3k+ large rows to another table in the same database without success

I have created a new column in the "destination" table with the same name, datatype and other values as appear in the "source" column in a different table. I have tried many suggested solutions as found on stackoverflow. This one appeared to work (found on Quora) but when I went to the destination table the previously empty column remains empty with nothing but NULL values noted. This is the Quora suggestion:
you can fill data in column from another existing one by using INSERT INTO statement and SELECT statement together like that
INSERT INTO `table1`(column_name)
SELECT column_name FROM `table2`
here you filled a single column in table 1 with data located in a single column in table 2
so if you want to fill the whole table 1 (all columns) with data located in table 2 you can make table 1 like a copy of table 2 by using the same code but without column name
INSERT INTO `table1`
SELECT * FROM `table2`
but note to do this (copy table content to another one) ensure that both of tables have the same column count and data types.
I'm not sure what is meant by column count (do the two table have to have the same number of columns?)
When I run it I get error # 1138.
Any help greatly appreciated. -JG

Insert Statement with result record values

I have a table with 50 columns, and the table has more than one lakh records.
My requirement is to get few desired records from the table and insert into another machine's database table.
Is there a way to extract the desired result records along with Insert statement? I tried doing with exporting the data, but it fetches all the records.
Any suggestions please?

updating all rows after specific record

I have a table containing an int column named "place". The values from the column determine the ordering of rows from the table on a page. It is for a blog like application. I want a query where I can update the 'place' column for all rows, including the current row, and all rows after the same.
Thanks for any help!
update topic set place = place + 1 where place >= 5

Not able to insert merge values in one row using ssis?

I have two excel source on one excel file 1st fetching value date and 2nd fetching value price
now i have tried merge then union all also to get those two values in one derived column
but when i execute my package it is inserting values separately.
like this into two rows one by one but i want to insert these two values in one row only.
for example this is my problem:
date price
12-12-2001 null
date price
null 54
but i want it in one row only like
date price
12-12-2001 54
Create two derived columns with the same value (i.e. call them id1 and id2 and set both to have a value of 1).
Change the sort to sort by the new id columns.
Change the merge component to a merge join and use the newly created ids to link the data based on an inner join
which will give you a single row