SQL SERVER – Create Script to Copy Database Schema and All The Objects – Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects

After reading a post from Pinal I am proposing another solution here to automate SQL backup infrastructure. The dditional advantage here in this approach is , the SQL objects are always created in a seperate file so this can be really helpful to compare your chages in DB from your last version.

Steps :

1. Get file 0g_SqlExtract.vbs  or from attachement to this post.

2. Create a small batch file to call this script. Its handy to call it via batch file I guess. Ofcourseyou can use it   directly.

3. Pass the required parameter to the batch file

SET SERVER=%1
SET DB=%2
SET OUTPUT_FOLDER=%3
SET LOGIN=%4
SET PASSWORD=%5

cscript 0g_sqlextract.vbs %SERVER% %DB% %OUTPUT_FOLDER% %LOGIN% %PASSWORD%

4. Execute your batch file .

 

Download scripts from here

Thats it.

Have a great day

Advertisements

One thought on “SQL SERVER – Create Script to Copy Database Schema and All The Objects – Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s