﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / SQL query statement for copying data from different rows to different rows / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 01:10:36 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>[quote][b]ChrisM@Work (10/9/2012)[/b][hr][quote][b]zahid_7777 (10/8/2012)[/b][hr]I just like to know the command to copy data (specific range like 10 rows) containing in a COMPANY_CODE and will be copied to another COMPANY_CODE starting with a new accounts_code  which will be different from the previous accounts_code in a same dbo.ACCOUNT_INFO table.I need to specify starting account_code and continued to the last data sequentially.Structure of the table likeCOMPANY_CODE  ACCOUNTS_CODE  ACCOUNTS    DESCRIPTION0001                  18-01-0001-001   AR-SALEs        ASSETS0001                  18-01-0001-002   AR-X              ASSETS0002                  18-01-0001-001     AR-y               ASSETS0002                  18-01-0001-002     AR-y               ASSETSlast two record should be coppied to the company code 0001 starting from a defined account code and continue to add with by incremented by in the accounts code.[/quote][code="sql"]-- please provide us with the business rules -- for generating the new account codesINSERT INTO MyTable (	COMPANY_CODE, 	ACCOUNTS_CODE, 	[ACCOUNTS DESCRIPTION])SELECT 	COMPANY_CODE = '0001', 	ACCOUNTS_CODE = ?, &amp;lt;&amp;lt;==== 	[ACCOUNTS DESCRIPTION]FROM MyTableWHERE COMPANY_CODE = '0002'	AND ACCOUNTS_CODE IN ('18-01-0001-001','18-01-0001-002')[/code][/quote]</description><pubDate>Wed, 10 Oct 2012 03:19:03 GMT</pubDate><dc:creator>Rauf Miah</dc:creator></item><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>[quote][b]zahid_7777 (10/8/2012)[/b][hr]I just like to know the command to copy data (specific range like 10 rows) containing in a COMPANY_CODE and will be copied to another COMPANY_CODE starting with a new accounts_code  which will be different from the previous accounts_code in a same dbo.ACCOUNT_INFO table.Structure of the table likeCOMPANY_CODE  ACCOUNTS_CODE  ACCOUNTS    DESCRIPTION0001                  18-01-0001-001   AR-SALEs        ASSETS0001                  18-01-0001-002   AR-X              ASSETS0002                  18-01-0001-001     AR-y               ASSETS0002                  18-01-0001-002     AR-y               ASSETSlast two record should be coppied to the company code 0001 starting from a defined account code and continue to add with by incremented by in the accounts code.[/quote][code="sql"]-- please provide us with the business rules -- for generating the new account codesINSERT INTO MyTable (	COMPANY_CODE, 	ACCOUNTS_CODE, 	[ACCOUNTS DESCRIPTION])SELECT 	COMPANY_CODE = '0001', 	ACCOUNTS_CODE = ?, &amp;lt;&amp;lt;==== 	[ACCOUNTS DESCRIPTION]FROM MyTableWHERE COMPANY_CODE = '0002'	AND ACCOUNTS_CODE IN ('18-01-0001-001','18-01-0001-002')[/code]</description><pubDate>Tue, 09 Oct 2012 01:23:27 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>I just like to know the command to copy data (specific range like 10 rows) containing in a COMPANY_CODE and will be copied to another COMPANY_CODE starting with a new accounts_code  which will be different from the previous accounts_code in a same dbo.ACCOUNT_INFO table.Structure of the table likeCOMPANY_CODE  ACCOUNTS_CODE  ACCOUNTS    DESCRIPTION0001                  18-01-0001-001   AR-SALEs        ASSETS0001                  18-01-0001-002   AR-X              ASSETS0002                  18-01-0001-001     AR-y               ASSETS0002                  18-01-0001-002     AR-y               ASSETSlast two record should be coppied to the company code 0001 starting from a defined account code and continue to add with by incremented by in the accounts code.</description><pubDate>Mon, 08 Oct 2012 22:38:11 GMT</pubDate><dc:creator>Rauf Miah</dc:creator></item><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>You need to replace the SELECT * with actual column names.</description><pubDate>Mon, 08 Oct 2012 07:11:43 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>SELECT *, [COMCOD]      ,[ACTCODE]      ,[ACTDESC]      ,[ACTELEV]      ,[ACTTYPE]      ,[ACTTDESC]      ,[USERCODE]  FROM [ASTREALERPDBR].[dbo].[ACINF]  WHERE [COMCOD]=3306 OR [COMCOD]=3307Result's are (small portion),COMCOD	ACTCODE	ACTDESC	ACTELEV	ACTTYPE	ACTTDESC	USERCODE	COMCOD	ACTCODE	ACTDESC3306	810100010002	Other's Income	2				3306	810100010002	Other's Income3306	810100010003	Associaltion Fee (Sales)					3306	810100010003	Associaltion Fee (Sales)3306	810100010004	Discount Received From Flat Owner					3306	810100010004	Discount Received From Flat Owner3307	110000000000	Non Current Assets					3307	110000000000	Non Current Assets3307	110100000000	Fixed Assets					3307	110100000000	Fixed Assets3307	110100010000	Fixed Assets					3307	110100010000	Fixed Assets3307	110100010001	Furniture &amp; Fixture	2	0101001			3307	110100010001	Furniture &amp; Fixture3307	110100010002	Telecommunication	2	0101001			3307	110100010002	Telecommunication3307	110100010003	Office Equipment	2	0101001			3307	110100010003	Office Equipment</description><pubDate>Mon, 08 Oct 2012 06:36:40 GMT</pubDate><dc:creator>Rauf Miah</dc:creator></item><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>Please attach a screenshot of sample data or post query which you wrote so that we can do modification in that and give you desired result,</description><pubDate>Mon, 08 Oct 2012 04:53:01 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>[quote][b]zahid_7777 (10/8/2012)[/b][hr]I have a table (dbo.ACCOUNT_INF) with fields company_code (secondary key), accounts_code (unique) and other columns. I like to copy rows containing a specific company_code and from accounts_code = 1 which is unique to accounts_code 100 along with full records (rows)  to a another company_code starting from a specific accounts_code in the same table dbo.ACCOUNTS_INF[/quote]Post a SELECT query which returns the rows you want to clone, we'll show you how to do the rest.</description><pubDate>Mon, 08 Oct 2012 03:11:20 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>Can you clarify the scenario with some sample data?</description><pubDate>Mon, 08 Oct 2012 03:09:10 GMT</pubDate><dc:creator>Bhumika Jawanjal</dc:creator></item><item><title>SQL query statement for copying data from different rows to different rows</title><link>http://www.sqlservercentral.com/Forums/Topic1369644-1292-1.aspx</link><description>I have a table (dbo.ACCOUNT_INF) with fields company_code (secondary key), accounts_code (unique) and other columns. I like to copy rows containing a specific company_code and from accounts_code = 1 which is unique to accounts_code 100 along with full records (rows)  to a another company_code starting from a specific accounts_code in the same table dbo.ACCOUNTS_INF</description><pubDate>Mon, 08 Oct 2012 01:39:02 GMT</pubDate><dc:creator>Rauf Miah</dc:creator></item></channel></rss>