SQL Prompt - 5.3
Splitting a table - SQL Prompt
SQL Prompt enables you to split a table in your database into two tables.
Splitting a table can be useful if you want to:
- normalize a database
For example, by moving columns to a new secondary table to avoid insert anomalies.
- improve database performance
For example, by moving large but rarely used columns to a secondary table.
- change the database design
For example, to enable storing multiple customer addresses.
Note: Splitting a table is available only in SQL Prompt Pro Edition.
Example: splitting a simple table
The following example demonstrates how SQL Prompt splits a table. In the example, we want to split a table with three columns, Name, ID and Category:

In the table, the value of ID determines the value of Category. When splitting the table, we can use SQL Prompt to:
- copy ID to a new secondary table
- move Category to a new secondary table
Preparation
If you copy any of the following to a secondary table, the split table script will fail:
- XML columns
- Columns that allow NULL values
- Timestamp columns
- Partitioned columns
Note that DML triggers that access data in the primary table are dropped when the table is split. You are strongly recommended to back up these triggers prior to launching the split table wizard.
For more detailed information, see Preparing the table in detail.
Splitting the table
To split a table:
- In the Object Explorer pane, right-click the table you want to split, and then click Split Table.
The Split Table wizard is displayed:

- In Secondary table name, type a name for the new secondary table.
You must enter a name that is not already in use.
If required, you can also select a new owner for the table.
- Click Next.

- To assign columns from the primary to the secondary table, select the column(s) and click the Copy > or Move > buttons.
Note that:
- you must copy at least one column to the secondary table so the tables can maintain a relationship
- you cannot move primary key columns
to the secondary table - you can select multiple columns to move, copy, or remove using Ctrl or Shift
To remove an assigned column from the secondary table, select the column and click < Remove.
To remove all of the assigned columns from the secondary table, click Reset All.
- If required, reorder the assigned columns in the secondary table using the
and
buttons.You can reorder multiple columns simultaneously.
- Click Next.

By default, a foreign key is created on the primary table, to reference the primary key on the secondary table. This is for 1:1 or m:1 relationships.
If you have copied all the primary key columns from the primary table to the secondary table, you can choose to create the foreign key on the secondary table, to reference the primary key on the primary table. This is for 1:1 or 1:n relationships.
- Click Next.
SQL Prompt creates the split table script and displays summary information:

- Actions is a summary of the actions that the script will perform, in the order in which they will occur.
- Warnings displays information that you should consider prior to running the script, including any reasons the script might fail.
- Dependencies lists objects that will be modified by the script because they reference, or are referenced by, the primary table.
The actions and warnings are included in the split table script, below the header. If you do not want to include this information in the script, clear the Include summary in the script check box.
- Click View Script.
The wizard is closed, and the split table script is displayed in a new SQL Server Management Studio query window.
You are recommended to back up your database before you run the script.
For detailed information describing what happens to your objects when you run the script, see What happens when I run the split table script?
- Once you have reviewed the script, run it.
Script failure or cancellation
If a script fails, or if it is cancelled, in most cases SQL Prompt uses transactions to roll back any changes.
SQL Prompt displays a warning message if it will be unable to roll back all the changes; in these cases, your database will be in an unknown state.
Was this article helpful?
SQL Prompt
- SSMS failed to load SQL Prompt add-in 80070002
- No SQL Prompt menu appears in Query Analyzer
- SQL Prompt is showing an old version of my stored procedure (version 3)
- Removing menu items after uninstalling SQL Prompt and SQL Refactor
- A newly-created table exists, but it is not visible in the candidate list (version 3)
- Configuring permissions for SQL Prompt
- Using Intellisense or auto complete with a VS Web project (version 3.5)
- Uninstalling the Visual Studio 2005 add-in
- Unable to cast object of type 'System.DBNull' to type 'System.String' (version 3)
- Suggestions to improve performance for pre-formatted SQL (version 3.9)
- Changing the location of the settings, cache files and snippets folders
- Saving SQL Prompt options (version 3)
- SQL 2008 installation fails with Express Tools rule (version 3.8)
- Add-in failing to load into SQL Server Management Studio on Vista
- Removing SQL Server Management Studio Integration after uninstallation
- Layout SQL Error
- Downgrading to SQL prompt 3.9 from 4.0
- Candidate suggestions being displayed slowly
- SQL Prompt is not showing all linked servers
- Log files
- Refreshing the cache
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Prompt
- Activating your products
- Activating your products
- Getting help offline
- Customizing SQL Prompt to write SQL code more efficiently
- SQL Prompt 3.xx - reducing memory usage to improve performance
- Using SQL Prompt 4: tips for SQL Prompt 3 users
- SQL Prompt release notes - version 4.xx
- Release notes - version 5.xx
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Using SQL Prompt