SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 to create a batch file for .sql files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

arthiasha
Starting Member

India
40 Posts

Posted - 10/09/2012 :  01:51:46  Show Profile  Reply with Quote
Hi,

I need to create a batch file with the scripts which is in .sql format.
table_schema.sql
stored procedures.sql
uddtypes.sql
uddtables.sql
grant permission.sql
sql injection.sql
users.sql

These files hold all scripts for creation of schema, stored procedures, users, uddt's etc
I need to create a single batch file so that when i run it, automatically the schema with stored procedures and everything should be created in my mssql 2008.

create table..... (execute 'table_schema')
create table.....(execute 'stored procedures')
....
...

it should be given like this
can u give me the script?

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/09/2012 :  07:05:45  Show Profile  Reply with Quote
In SQL Server Management Studio, in object explorer, right-click on the database name and select Tasks -> Generate Scripts and follow through the wizard.

If you are trying to port a database from one server to another, there are other ways as well - backup and restore, SSIS etc.
Go to Top of Page

arthiasha
Starting Member

India
40 Posts

Posted - 10/09/2012 :  07:46:58  Show Profile  Reply with Quote
Thanks for your relpy, but i dont want to do this way because i need to use this as a deploy script to create a new database with its schema etc..as well as bcp it.

I wanted a script like
create database [dbname]
...
(call all the .sql scripts-table schema,procedures etc
....
....

so that it creates the whole database with its schema procedure uudtypes etc.
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/09/2012 :  07:55:28  Show Profile  Reply with Quote
I am afraid I did not follow the requirement.

If you are trying to create a database with all the schema objects and none of the data, what I described above would work. You will generate the scripts once (which is a manual process), and then use that script to create your deployment package/script.

You also mentioned BCP. If you are trying to deploy the database with the data, backup and restore may be a better option. That also can be scripted.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000