0

In my first database named 'sshopping' has two tables IndiaStates and IndiaCity. I want to copy these both table in new database 'jaijinendera' .

IndiaStates has columns StateID (Primary Key) and StateName

IndiaCity has columns CityID(Primary Key) , StateID (Foreign Key),CityName

I used the query something like this

   Insert int jaijinendera..IndiaStates select * from sshopping..IndiaStates
   Insert int jaijinendera..IndiaCity select * from sshopping..IndiaCity

this has copied the data but not the keys (structure). What query should i made to copy proper structure and data from sshopping to jaijinendera

VJain
  • 1,027
  • 7
  • 17
  • 37
  • possible duplicate of [Duplicate a table including indexes](http://stackoverflow.com/questions/18017961/duplicate-a-table-including-indexes) – Dan Oct 12 '13 at 10:59
  • Why not take a back up and restore it with a different name. – Kaf Oct 12 '13 at 11:16
  • how to take backup of only two tables in database explain plz – VJain Oct 12 '13 at 11:23

1 Answers1

0

Try using the SQL Server Generate script.

Right click on DB where you want to export table structure and data. Select Task and generate script. follow the wizard. Select the object or entire database in the select object you want to generate script. Click on the Advance to select schema only (for structure)/ data only for data and schema and data for both.

generate the script to file or clipboard.

Miller
  • 1,096
  • 9
  • 22