Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Batch File Stored procedure

Author  Topic 

SophieMarceau
Starting Member

6 Posts

Posted - 2005-11-10 : 06:54:22
Oh please, anyone tell me!

How can I run a damned stored procedure from outside SQL Server. Can I do it at all?

I mean not with "EXEC mystoredprocedure"
but through a batch file?

Please help me.

ty



madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-10 : 07:02:43
You can make use of osql

Click Start-->Run and type this and Press Enter

osql -E -d DBName -S ServerName-Q "Exec yoursp ; SELECT [RowCount] = @@ROWCOUNT" -o C:\osql.txt

Now the result of stored procedure will be in C:\osql.txt

Refer isql, osql in SQL Server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SophieMarceau
Starting Member

6 Posts

Posted - 2005-11-10 : 07:56:36
TY Madhivanan!

Its my fault, my explaination was not sufficient. I have created a stored procedure not for me but for other people. They have no idea how to start and run everything under MS SQL Server interface. What they can do is pushing a button (or somethimg of that kind), that is supposed to start the whole procedure.

And this is my problem. I thought it was possible to create a "file.bat" or something put it on the desktop on somewhere else.

It is too sophisticated for my user to type all that stuff under Start --> Run

I hope, you understand what I mean, Madhivanan.

Thank you
Go to Top of Page

SophieMarceau
Starting Member

6 Posts

Posted - 2005-11-10 : 10:57:21
Nobody answers...
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2005-11-10 : 13:07:47
What does it do IE can you just schedule it to run every 15 min or do.

Put it on a web page and give them a login to run the procedure.

Create a small C/VB/whatever program to do it. Otherwise you are going to have to install the SQL Server tools on each clients machine.


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

SophieMarceau
Starting Member

6 Posts

Posted - 2005-11-10 : 13:56:54
Stephen, the client is already installed. Now the problem is as follows: they dont want get through all the "jungles". I showed them the path:
SQL Server --> Enterprise Manager --> Server --> Group --> Database --> Stored Procedures --> Procedure name --> rightClick --> open --> Execute

Obviously it is too long. Can I do the same without starting MS SQL Server? Can I organize the same with one click and without typing the whole chain that Madhivanan showed me (see above).

I mean, it should be a solution with a batch file. I did the same a couple of years ago with "Java Visual Age".

Or is the there really no alternative to VB or something of that kind?

Thank you Stephen anyway.
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2005-11-10 : 14:07:24
If the client is already installed just add Madhivanan's line to a batch file.
The have the Network guys copy it to the machine when a user logs in.


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

SophieMarceau
Starting Member

6 Posts

Posted - 2005-11-14 : 12:25:46
Thanks a lot, jhocutt!

I coped with that. The next problem I face - to organize the same thing with DTS-Package. I have to export a package from a command line or better a batch file but I dont know how to address this DTS-Package.

I have nothing in "Help". Does anyone know how it goes?

Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2005-11-14 : 12:45:03
Look at DTSRun.
Or just schedule the package then copy the command from the schedule and delete the schedule.


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

SophieMarceau
Starting Member

6 Posts

Posted - 2005-11-14 : 12:59:20
Sorry i dont understand what you mean under "schedule package".
Could you please tell me?
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2005-11-14 : 13:21:29
Look up
How to schedule a DTS package using the Schedule Package option (Enterprise Manager)
in BOL

"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page
   

- Advertisement -