3

I want to convert a database into an sql script so that i can recreate it elsewhere. I want the copy to be same as original.

How do i do that ?

2 Answers 2

6

You can generate DB Script using Management Studio through available option.

Right Click on Database -> Task -> Generate Scripts

enter image description here

Here is an option for including Data with Schema in script

Sign up to request clarification or add additional context in comments.

7 Comments

The database is copied, but with some errors. I am ignoring the errors for now. Main thing is There are no rows in any of the tables !!! How do i get the rows also in my script, ie insert into....?
There is an option 'Advanced' on Set Scripting option screen. Click on that and check Type of Data to script, select its value to Schema and Data. then it will also include the data.
Also, if you want to simply get the exact same database somewhere else, you may want to do a backup to disk, copy the file, and restore it on the other server. This way it will take with it everything (data schema, etc.)
@Sachin - Type of Data to script option is not present. Probably, disabled by admin???
@Arsen - tried that. but db is on remote server. I can rdp into remote server, but cant copy paste backup into local. I was hoping to copy to local and then upload that copy to another server. Well i guess thats not gonna happen.
|
1

In SQL Management Studio, right click on the database, select Tasks->Generate Scripts. It will guide you through a wizard.

1 Comment

The database is copied, but with some errors. I am ignoring the errors for now. Main thing is There are no rows in any of the tables !!! How do i get the rows also in my script, ie insert into....?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.