Solved

run sql files through batch file

Posted on 2013-01-01
3
429 Views
Last Modified: 2013-01-01
i need to run few sql files that hv stored procudures in them through a batch files , i dont know anything much abt how to do that , plz help with an example
0
Comment
Question by:panasonic2012
  • 2
3 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38735713
sqlcmd -E -S yoursqlinstance -i backup.sql
refer for more details
http://stackoverflow.com/questions/3294545/how-to-run-sql-file-from-a-batch-file
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 38735714
1) First Open one new notepad
then

write the sql commands that you want to excute

like this for example

USE MASTER
go
SELECT * FROM SYSDATABASES
go

now save the file with .sql suppose say (example.sql)


2) now open another notepad in the same folder

write the following code


osql -S servername -U username -P password <example.sql
pause

save this as .bat extension (this will create the batch file) file

3) double click on the batch file it will excute the commands

refer
http://www.sqlservercentral.com/Forums/Topic501783-8-1.aspx
0
 

Author Comment

by:panasonic2012
ID: 38735762
ok i ran it and it works fine , now i need is to run the batch file to another pc on the network so the sql execution occurs on tht pc , how do i achieve this ?? plz help
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Switching Visual Studio 2015 to normal debug display 3 27
How to search for strings inside db views 4 28
SQL Improvement  ( Speed) 14 28
C# LINQ ForEach() question 6 28
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question