Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Template table used in my newly created database

Author  Topic 

Goldmember
Starting Member

9 Posts

Posted - 2008-06-18 : 21:09:29
I created a database called sports and then created a table which I'm going to use as a template for other tables within the same database.

What is the proper way to structure and implement copying this template table?

Should I store the template table under the system tables folder?

How do I copy the template table and create a new table from this template?

Thanks you
Goldmember

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-06-18 : 21:55:05
You can script it.
Go to Top of Page

Goldmember
Starting Member

9 Posts

Posted - 2008-06-18 : 22:01:56
I found out how using the Select statement

http://lists.evolt.org/archive/Week-of-Mon-20030428/139724.html

SELECT * INTO table_name FROM template_table

Thanks
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-06-19 : 08:36:55
Be aware that the SELECT * INTO doesn't copy indexes or constraints.

EDIT: there are a few issues with the SELECT INTO syntax, i.e. it doesn't copy primary/foreign key constraints etc. You should look it up in BOL to make sure that it meets all your requirements.

- Lumbago
Go to Top of Page
   

- Advertisement -