how to copy table structure from one Database to another database

How to copy tables structure from one Database and paste to another database

i am newbie for SQL Server 2008 R2
Who is Participating?
AnujConnect With a Mentor SQL Server DBACommented:
I would say to go for generate script task, Right click the source database, Select Tasks -> generate script wizard, This wizard will guide you to script the objects in a database. You can query all the objects in a database, or selected objects. The script can be saved in a New Query window, or file or in a clip board.
alpmoonConnect With a Mentor Commented:
The easiest way is using 'select into':

select * into otherdb..newtable from currenttable where 1=2
vastoConnect With a Mentor Commented:
If you wan to copy just the structure then in Management Studio right click on the table  and select "Script Table As" ->"Create To"->"New Query Editor Window".  This will create a script which you can run in the other database and create the table. The script will start with

USE [CurrentDatabaseName]

These lines should be removed before to run the script in the new database
crystal_TechAuthor Commented:
SQL Server Management Studio's "Import Data" task (right-click on the DB name, then tasks) will do most of this for you. Run it from the database you want to copy the data into.

If the tables don't exist it will create them for you, but you'll probably have to recreate any indexes and such. If the tables do exist, it will append the new data by default but you can adjust that (edit mappings) so it will delete all existing data.

above solution is working for me.. thanks
crystal_TechAuthor Commented:
Thanks for quick answer. :-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.