List of Topics

SfC Home > Web Design > SQL > ColdFusion >

Populating a New Database Table from and Old Table with ColdFusion

by Ron Kurtus (updated 27 May 2023)

Supposed you have created a new database table, and you want to populate it with data from another table. You can use the Macromedia ColdFusion <CFLOOP> tag and the SQL INSERT function to perform that task.

Steps to take are:

  1. Create new table
  2. Create CF page with Query, Loop and Insert
  3. Test application

This lesson will answer those questions.

Create new table

First, you need to create the new table in your database and enter the names, types and sizes of its columns or fields. The names do not have to be the same as the fields in the first database, but the types and sizes should be.

Create CF page

Then, create a ColdFusion page where you query, loop and insert your data.

Query old table

Query the old table for its data. This table may be in the same database or in a different one.

FROM TableName

Loop and insert

Loop over this query and insert the records or rows into the new table.

<CFLOOP Query="first">

INSERT INTO New_TableName(


Remember to add the single quotation marks ( ' ) for the text data items. Also, note that the names from the first table do not necessarily have be the same as what you enter in the second table.

Test application

Upload the page and run the application. You may get error message for data mismatches or such. Make the appropriate adjustments.

You can also use this method to add or update data in you new table from the original.


To populate new database table with data from another table, you can use the <CFLOOP> tag and the SQL INSERT function to perform that task.

Help others succeed

Resources and references

Ron Kurtus' Credentials


ColdFusion Resources


(Notice: The School for Champions may earn commissions from book purchases)

Top-rated books on ColdFusion

Students and researchers

The Web address of this page is:

Please include it as a link on your website or as a reference in your report, document, or thesis.

Copyright © Restrictions

Where are you now?

School for Champions

ColdFusion topics

Populating a New Database Table from an Old Table

ColdFusion topics


Development methods

Specific applications

Also see

Let's make the world a better place

Be the best that you can be.

Use your knowledge and skills to help others succeed.

Don't be wasteful; protect our environment.

You CAN influence the world.

Live Your Life as a Champion:

Take care of your health

Seek knowledge and gain skills

Do excellent work

Be valuable to others

Have utmost character

Be a Champion!

The School for Champions helps you become the type of person who can be called a Champion.