How to script whole database in SQL server [Resolved]

Posted by Karthikanbarasan under Sql Server on 3/4/2011 | Points: 10 | Views : 9559 | Status : [Member] [Moderator] [Microsoft_MVP] [MVP] | Replies : 6
HI,

I want to script my whole database into a file(All tables, stored procedures, views, functions and also Data). Is there any simplest way to do that in SQL Server

Thanks
Karthik
www.f5Debug.net



Responses

Posted by: Rahuljgosavi on: 3/8/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Karthik,

Yes you can generate the script for Data also in SQL 2008,

Below are the steps,
1.Right click on Database
2.Select 'Tasks', in that select 'Generate Scripts'
3.Select Next and select again the database for which you need a script.
4.Now here you can see the "Choose Script Option",scroll down below you can see the "Table/View Options"
5. In that set Script Data = True and then proceed (This will include data also with schema for tables)

I am attaching screenshot with this.

Cheers,
Rahul Gosavi
 Download source file

Karthikanbarasan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SheoNarayan on: 3/4/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Karthik,

I think you can script your database structure and other objects through SQL Server Management studio (right click the database and Script As ...) but data doesn't go with them.

To backup your data in the file, you can use this article I had written long back http://www.dotnetfunda.com/articles/article489-backup-and-restore-database-in-aspnet-.aspx.

Thanks


Regards,
Sheo Narayan
http://www.dotnetfunda.com

Karthikanbarasan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/4/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Please go thru the Step by step process on how to generate scripts in the article which I had written

http://www.dotnetfunda.com/articles/article1240-generate-sql-server-scripts-using-wizard-.aspx

In this in the Choose Script Options screen you can set one option called Script Data = true to generate script for the data also along with other scripts..

Let me know if you need any other details

Thanks and Regards
Madhu

Karthikanbarasan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/4/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Thanks Sheo and Madhu...

Thanks
Karthik
www.f5Debug.net

Karthikanbarasan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/8/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

I can able to do the objects scrptin... is there any option for all the datas to be scripted? like all the tables data to be scripted into an insert statement.

Thanks
Karthik
www.f5Debug.net

Karthikanbarasan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/10/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Thanks Rahul... It worked for me...

This option is avilable only with SQL Server 2008...

Thanks
Karthik
www.f5Debug.net

Karthikanbarasan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response