How to backup Sql Server to sql file? How to backup Sql Server to sql file? database database

How to backup Sql Server to sql file?


Use SQL Server's Generate Scripts commend

  • right click on the database; Tasks -> Generate Scripts
  • select your tables, click Next
  • click the Advanced button
  • find Types of data to script - choose Schema and Data.
  • you can then choose to save to file, or put in new query window.
  • results in CREATE and INSERT statements for all table data selected in bullet 2.

SQL Server Generate Scripts Data


This is a possible duplicate of: SQL script to get table content as "SELECT * FROM tblname"

To do a full database backup to File/Query you can use the 'Generate Scripts...' option on the Database.

Open SQL Server Management studio, right click on the database and choose 'Tasks->Generate Scripts...'

Then use the wizard to backup the database. You can script the whole database or parts of it. Two important options: In the 'Advanced' section, you will probably want to ensure 'Type of backup = 'Schema and Data' and the 'Script Statistics' is on.

This will produce a *.sql file that you can use as a backup that includes the schema and table data.


Ok, I read through most of these, but I had no "advanced button". But, there is still a way to do it, it's just a little hard to find, so here you go:

enter image description here