How to load sql files from command line

How can I load .sql files via command line into a sql db?
goretailproAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ramesh Babu VavillaConnect With a Mentor Commented:
parameter is as below


sqlcmd -E -S .\SQLEXPRESS -i scriptfile.sql -o RestoreDB.log

0
 
effesCommented:
Hi goretailpro,

SQL Server comes with a command line utility called "sqlcmd". You can read all about it's use here.

Hope that helps.
0
 
Anthony PerkinsCommented:
You are looking for the -i parameter when using SQLCmd.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
Ramesh Babu VavillaConnect With a Mentor Commented:
sqlcmd -E -S
.\SQLEXPRESS   server name
-i Restore_And_Create_User _Script.sql   sqlscript
 -o RestoreDB.log   logfile to write the result
0
 
Ramesh Babu VavillaCommented:
0
 
Ramesh Babu VavillaCommented:
just rename the txt file to a batch name (.bat)
user.txt
0
 
goretailproAuthor Commented:
Is there a way to have this done as a wild card with any SQL scripts?
0
 
goretailproAuthor Commented:
right now Every xml files comes across like this "109000773.2011-08-12-12-37-28.f.sql"  the first digit's is always stay the same.  Any suggestions..
0
 
Anthony PerkinsCommented:
>>Is there a way to have this done as a wild card with any SQL scripts? <<
While the -i parameter does not accept wild cards there is nothing stoping you from using a batch file or a VBScript to fill them.  Alternatively you can list all the SQL queries one after the other as in:
-i file1.sql, file2.sql, file3.sql,...
0
 
goretailproAuthor Commented:
Do you know of a 3rd party software that can look at a folder and load all SQL files into a db?
0
 
Anthony PerkinsCommented:
No.  You can certainly do that with SSIS, it is just that you will have to roll up your sleaves and create an SSIS package to do it.  On the other hand if you are using SQL Express, than SSIS is not an option.
0
 
goretailproAuthor Commented:
Any suggestions on these templates that can start me in the correct direct?

http://msftisprodsamples.codeplex.com/
0
 
Anthony PerkinsCommented:
I am afraid I have no idea.
0
 
goretailproAuthor Commented:
Do you know of a place online that is good for getting bids for this project?
0
All Courses

From novice to tech pro — start learning today.