0

I have a database in my sql management studio how can script the database schema to file so that I can put it in another device?

thanks

3
  • 2
    I have no idea what you're asking, unless you're asking how to write queries. Commented Dec 26, 2010 at 12:07
  • i have a database all i need is to make it as a query when u execute it you will see a new database added to your sql management studio Commented Dec 26, 2010 at 12:23
  • @Bobj-c - I edited your question to try to make it more clear. If I've misinterpreted, please edit it. Commented Dec 26, 2010 at 12:49

3 Answers 3

3

Open SQL Management -> Script Database As -> .... I think its the closest to what you mean.

Of course there are 3rd party tools for these kind of works. See RedGate.

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

1 Comment

In SQL Management Studio, right click database choose Tasks - Generate Scripts...
1

Shutdown SQL Server, copy the MDF and LDF Files to a new server and attach them on that instance by right clicking on Databases and choosing Attach. Specify the location of the files.

Alternatively, you could also backup the database from the source and restore it in the destination.

The above two methods copy all data too. If you want only the schema, Right click on the database and choose Generate SQL Scripts and follow the instructions.

4 Comments

i know about attach but i want to make it query because i need to send it by e-mail and i'm in a country 128kb max connection so i can send 8 mb database (no upload) through mail got the point
RAR the database after you Detach it and if you need specific size files, just cut in pieces, you can choose file size when you compress it. Send by mail, get the pieces, unrar and attach to server. Else you could create a schema script using a tool and create a data script using another tool. RedGate does both.
i tried in the best mode will be 5 mb . trust me if i cant upload more than 30kb imagine 5 mb divided by 30 kb almost 160 chunk (not good idea)
I strongly suggest against using a script. All your identity columns will get regenerated which may break foreign key relationships. The best way is to backup and restore or detach and attach. Go to the database settings and choose Logging mode as simple - This will truncate the log file. Also shrink the database before backing up or detaching. After that, compress using RAR. You should get about 80% compression.
0

SQL Management Studio 2008 can make query to unload Schema and data from database, but older versions if Management studio can't do it. You can use another soft to do it like an EMS SQL Management studio

Comments

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.