i want to export data and schema from live Database to my local database, i tried "export data" option while right clicking on live db but it only exports data but not constraints on columns. kindly help me out?
1 Answer
Try this:
- Open SQL Server Management Studio.
- Choose the database and click with right button.
- Tasks > Generate Scripts...
- Next.
- Select the objects (tables, etc) or select the entire database and click next.
- Click Advanced button and select what do you want. There is an option "Types of data to script", select "Schema and data".
- Next
If the database is big you will need to execute the script using the prompt in your local database.
3 Comments
Noman Ahmad
all is good except shows error in "USE [master] CREATE DATABASE [leadattendant] ON PRIMARY ( NAME = N'leadattendant', FILENAME = N'c:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\leadattendant.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB"
Rodrigo Kiguti
What is the message error? Are you logged as "sa" user? I suggest you create manually your local database, with user and schema, and generate the script only for Tables, Views, Stored Procedures and User-Defined Functions.
Rodrigo Kiguti
Don't forget to choose the "Schema and data" option in the Advanced button.