Wednesday, March 28, 2012
running a script which accepts a parameter against SQL2000 database
I'm fairly new to this stuff - I want to write a batch file or small
vbscript app that will aceept a parameter and then insert this into a
simple update command and execute agaisnt a SQL2000 database. andy help
appreciated!!
Cheers,
Paulat this link you can find about connecting to SQL server and adding new
records to a table using ADO
http://www.microsoft.com/technet/scriptcenter/scripts/misc/database/default.mspx?mfr=true
for using command line arguments, this link:
http://www.microsoft.com/technet/scriptcenter/resources/tales/sg0704.mspx
--
urkec
"pauls1888" wrote:
> Hi there,
> I'm fairly new to this stuff - I want to write a batch file or small
> vbscript app that will aceept a parameter and then insert this into a
> simple update command and execute agaisnt a SQL2000 database. andy help
> appreciated!!
> Cheers,
> Paul
>|||Look up batch files, using replaceable parameters, and then using SQL Server
Books Online, check out osql.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"pauls1888" <pauls1888@.gmail.com> wrote in message
news:1164726964.399837.44300@.45g2000cws.googlegroups.com...
> Hi there,
> I'm fairly new to this stuff - I want to write a batch file or small
> vbscript app that will aceept a parameter and then insert this into a
> simple update command and execute agaisnt a SQL2000 database. andy help
> appreciated!!
> Cheers,
> Paul
>|||Thanks for the help guys
running a script which accepts a parameter against SQL2000 database
I'm fairly new to this stuff - I want to write a batch file or small
vbscript app that will aceept a parameter and then insert this into a
simple update command and execute agaisnt a SQL2000 database. andy help
appreciated!!
Cheers,
Paul
at this link you can find about connecting to SQL server and adding new
records to a table using ADO
http://www.microsoft.com/technet/scriptcenter/scripts/misc/database/default.mspx?mfr=true
for using command line arguments, this link:
http://www.microsoft.com/technet/scriptcenter/resources/tales/sg0704.mspx
urkec
"pauls1888" wrote:
> Hi there,
> I'm fairly new to this stuff - I want to write a batch file or small
> vbscript app that will aceept a parameter and then insert this into a
> simple update command and execute agaisnt a SQL2000 database. andy help
> appreciated!!
> Cheers,
> Paul
>
|||Look up batch files, using replaceable parameters, and then using SQL Server
Books Online, check out osql.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"pauls1888" <pauls1888@.gmail.com> wrote in message
news:1164726964.399837.44300@.45g2000cws.googlegrou ps.com...
> Hi there,
> I'm fairly new to this stuff - I want to write a batch file or small
> vbscript app that will aceept a parameter and then insert this into a
> simple update command and execute agaisnt a SQL2000 database. andy help
> appreciated!!
> Cheers,
> Paul
>
|||Thanks for the help guys
sql
running a script which accepts a parameter against SQL2000 database
I'm fairly new to this stuff - I want to write a batch file or small
vbscript app that will aceept a parameter and then insert this into a
simple update command and execute agaisnt a SQL2000 database. andy help
appreciated!!
Cheers,
PaulLook up batch files, using replaceable parameters, and then using SQL Server
Books Online, check out osql.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"pauls1888" <pauls1888@.gmail.com> wrote in message
news:1164726964.399837.44300@.45g2000cws.googlegroups.com...
> Hi there,
> I'm fairly new to this stuff - I want to write a batch file or small
> vbscript app that will aceept a parameter and then insert this into a
> simple update command and execute agaisnt a SQL2000 database. andy help
> appreciated!!
> Cheers,
> Paul
>|||Thanks for the help guys
Monday, March 26, 2012
Running a package from another computer with DTSRunUI
the script with DTSRunUI. I cannot run it on another computer. Do I have t
o
copy DTSRun.exe to the other computer with the related rll files to get it t
o
run ? Is there a recommended way to do this ?It sounds like you are looking for the steps on
redistributing DTS. You can find information on this in the
Redist.txt file on the installation CD/DVD for SQL Server.
The dts.com web site has a great article on redistribution:
Redistributing DTS with your program
http://www.sqldts.com/default.aspx?225
-Sue
On Wed, 16 Aug 2006 10:12:02 -0700, rmcompute
<rmcompute@.discussions.microsoft.com> wrote:
>I set up a package with runs from a batch file on my computer after creatin
g
>the script with DTSRunUI. I cannot run it on another computer. Do I have
to
>copy DTSRun.exe to the other computer with the related rll files to get it
to
>run ? Is there a recommended way to do this ?
Running a Batch File in Query Analyzer
I have to run a batch file in query analyzer. How do I do that.
I don't want to use 'xp_cmdshell'
Please advise
(An example would be great)
Regards
IT Dev
File->Open, browse and find the file, and when it is open hit F5...
If you're looking for an non-interactive way to run a file, you might check
out the OSQL command-line tool that ships with SQL Server. It is documented
in Books Online.
Adam Machanic
SQL Server MVP
Author, "Expert SQL Server 2005 Development"
http://www.apress.com/book/bookDisplay.html?bID=10220
"IT Developer" <ITDeveloper@.discussions.microsoft.com> wrote in message
news:7DE905C4-EF0B-45CB-B109-6E63894D38BA@.microsoft.com...
> Hi,
> I have to run a batch file in query analyzer. How do I do that.
> I don't want to use 'xp_cmdshell'
>
> Please advise
> (An example would be great)
> Regards
> IT Dev
|||IT Developer wrote:
> I have to run a batch file in query analyzer. How do I do that.
> I don't want to use 'xp_cmdshell'
Why don't you?
|||Hello,
You will have to use XP_CMDSHELL if you need to execute the .BAT from Query
Analyzer. There is no other alternative.
Thanks
Hari
"IT Developer" <ITDeveloper@.discussions.microsoft.com> wrote in message
news:7DE905C4-EF0B-45CB-B109-6E63894D38BA@.microsoft.com...
> Hi,
> I have to run a batch file in query analyzer. How do I do that.
> I don't want to use 'xp_cmdshell'
>
> Please advise
> (An example would be great)
> Regards
> IT Dev
Running a Batch File in Query Analyzer
I have to run a batch file in query analyzer. How do I do that.
I don't want to use 'xp_cmdshell'
Please advise
(An example would be great)
Regards
IT Dev
I answered this question in the microsoft.public.sqlserver.programming.
Please don't post the same question independently to different groups
because that causes duplicate effort among the parties involved. You can
instead post the question once to all relevant groups so that the all
responses are tracked as a single thread.
Hope this helps.
Dan Guzman
SQL Server MVP
"IT Developer" <ITDeveloper@.discussions.microsoft.com> wrote in message
news:5D65C0C7-EABB-4A33-8C24-118C3CAC08F7@.microsoft.com...
> Hi,
> I have to run a batch file in query analyzer. How do I do that.
> I don't want to use 'xp_cmdshell'
>
> Please advise
> (An example would be great)
> Regards
> IT Dev
>
Running a Batch File in Query Analyzer
I have to run a batch file in query analyzer. How do I do that.
I don't want to use 'xp_cmdshell'
Please advise
(An example would be great)
Regards
IT DevI answered this question in the microsoft.public.sqlserver.programming.
Please don't post the same question independently to different groups
because that causes duplicate effort among the parties involved. You can
instead post the question once to all relevant groups so that the all
responses are tracked as a single thread.
Hope this helps.
Dan Guzman
SQL Server MVP
"IT Developer" <ITDeveloper@.discussions.microsoft.com> wrote in message
news:5D65C0C7-EABB-4A33-8C24-118C3CAC08F7@.microsoft.com...
> Hi,
> I have to run a batch file in query analyzer. How do I do that.
> I don't want to use 'xp_cmdshell'
>
> Please advise
> (An example would be great)
> Regards
> IT Dev
>
Running a Batch File in Query Analyzer
I have to run a batch file in query analyzer. How do I do that.
I don't want to use 'xp_cmdshell'
Please advise
(An example would be great)
Regards
IT DevI answered this question in the microsoft.public.sqlserver.programming.
Please don't post the same question independently to different groups
because that causes duplicate effort among the parties involved. You can
instead post the question once to all relevant groups so that the all
responses are tracked as a single thread.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"IT Developer" <ITDeveloper@.discussions.microsoft.com> wrote in message
news:5D65C0C7-EABB-4A33-8C24-118C3CAC08F7@.microsoft.com...
> Hi,
> I have to run a batch file in query analyzer. How do I do that.
> I don't want to use 'xp_cmdshell'
>
> Please advise
> (An example would be great)
> Regards
> IT Dev
>
running a batch file
manually its works fine, but when I schedule it on job managment from SQL
2000 it doesnt work.
Help me pleaseProbably service account and permissions problems. Verify that Agent has the needed permissions.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
news:0DF4CDB5-4C6A-49AA-A798-4B56DFCDA65D@.microsoft.com...
>I have a Batch file to use ssh connection. So When I run the batch file
> manually its works fine, but when I schedule it on job managment from SQL
> 2000 it doesnt work.
> Help me please|||ok thanks for yor answer but the user has permission to run the service, In
fact the user can run other batch files.
I debug the batch and this is the result:
Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command scp -v
-t WEBDSP.TXT
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.7.1p2
debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
-- last line --
This results is when I run from SQL Server, but if a run it from command
console the result is this
Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command
-t WEBDSP.TXT
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.
debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '10.10.10.1' is known and matches the RSA host key.
debug1: Found key in /home/ottod/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-i
ve
debug1: Next authentication method: publickey
debug1: Offering public key: id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: read PEM private key done: type DSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: scp -v -t WEBDSP.TXT
Sending file modes: C0777 3894 webdsp.txt
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.8 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0
What do you think?
"Tibor Karaszi" wrote:
> Probably service account and permissions problems. Verify that Agent has the needed permissions.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
> news:0DF4CDB5-4C6A-49AA-A798-4B56DFCDA65D@.microsoft.com...
> >I have a Batch file to use ssh connection. So When I run the batch file
> > manually its works fine, but when I schedule it on job managment from SQL
> > 2000 it doesnt work.
> >
> > Help me please
>|||> ok thanks for yor answer but the user has permission to run the service,
I don't understand what you mean by above. When agent executes something, it is executed in agents
service user context, not the user who owns the job.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
news:F10E7461-4A0B-49A5-8087-432269318F23@.microsoft.com...
> ok thanks for yor answer but the user has permission to run the service, In
> fact the user can run other batch files.
> I debug the batch and this is the result:
> Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command scp -v
> -t WEBDSP.TXT
> OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
> debug1: Reading configuration data /etc/ssh_config
> debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
> debug1: Connection established.
> debug1: identity file id_dsa type 2
> debug1: Remote protocol version 1.99, remote software version OpenSSH_3.7.1p2
> debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
> debug1: Enabling compatibility mode for protocol 2.0
> debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
> debug1: SSH2_MSG_KEXINIT sent
> debug1: SSH2_MSG_KEXINIT received
> debug1: kex: server->client aes128-cbc hmac-md5 none
> debug1: kex: client->server aes128-cbc hmac-md5 none
> debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
> debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
> -- last line --
> This results is when I run from SQL Server, but if a run it from command
> console the result is this
> Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command
> -t WEBDSP.TXT
> OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
> debug1: Reading configuration data /etc/ssh_config
> debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
> debug1: Connection established.
> debug1: identity file id_dsa type 2
> debug1: Remote protocol version 1.99, remote software version OpenSSH_3.
> debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
> debug1: Enabling compatibility mode for protocol 2.0
> debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
> debug1: SSH2_MSG_KEXINIT sent
> debug1: SSH2_MSG_KEXINIT received
> debug1: kex: server->client aes128-cbc hmac-md5 none
> debug1: kex: client->server aes128-cbc hmac-md5 none
> debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
> debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
> debug1: Host '10.10.10.1' is known and matches the RSA host key.
> debug1: Found key in /home/ottod/.ssh/known_hosts:1
> debug1: ssh_rsa_verify: signature correct
> debug1: SSH2_MSG_NEWKEYS sent
> debug1: expecting SSH2_MSG_NEWKEYS
> debug1: SSH2_MSG_NEWKEYS received
> debug1: SSH2_MSG_SERVICE_REQUEST sent
> debug1: SSH2_MSG_SERVICE_ACCEPT received
> debug1: Authentications that can continue: publickey,password,keyboard-i
> ve
> debug1: Next authentication method: publickey
> debug1: Offering public key: id_dsa
> debug1: Server accepts key: pkalg ssh-dss blen 433
> debug1: read PEM private key done: type DSA
> debug1: Authentication succeeded (publickey).
> debug1: channel 0: new [client-session]
> debug1: Entering interactive session.
> debug1: Sending command: scp -v -t WEBDSP.TXT
> Sending file modes: C0777 3894 webdsp.txt
> debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
> debug1: channel 0: free: client-session, nchannels 1
> debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.8 seconds
> debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
> debug1: Exit status 0
>
> What do you think?
> "Tibor Karaszi" wrote:
>> Probably service account and permissions problems. Verify that Agent has the needed permissions.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>> Blog: http://solidqualitylearning.com/blogs/tibor/
>>
>> "jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
>> news:0DF4CDB5-4C6A-49AA-A798-4B56DFCDA65D@.microsoft.com...
>> >I have a Batch file to use ssh connection. So When I run the batch file
>> > manually its works fine, but when I schedule it on job managment from SQL
>> > 2000 it doesnt work.
>> >
>> > Help me please
>>|||the user can run the agent, because I created others job and run fine
"jdonaldo" wrote:
> I have a Batch file to use ssh connection. So When I run the batch file
> manually its works fine, but when I schedule it on job managment from SQL
> 2000 it doesnt work.
> Help me pleasesql
running a batch file
manually its works fine, but when I schedule it on job managment from SQL
2000 it doesnt work.
Help me please
Probably service account and permissions problems. Verify that Agent has the needed permissions.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
news:0DF4CDB5-4C6A-49AA-A798-4B56DFCDA65D@.microsoft.com...
>I have a Batch file to use ssh connection. So When I run the batch file
> manually its works fine, but when I schedule it on job managment from SQL
> 2000 it doesnt work.
> Help me please
|||ok thanks for yor answer but the user has permission to run the service, In
fact the user can run other batch files.
I debug the batch and this is the result:
Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command scp -v
-t WEBDSP.TXT
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.7.1p2
debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
-- last line --
This results is when I run from SQL Server, but if a run it from command
console the result is this
Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command
-t WEBDSP.TXT
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.
debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '10.10.10.1' is known and matches the RSA host key.
debug1: Found key in /home/ottod/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-i
ve
debug1: Next authentication method: publickey
debug1: Offering public key: id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: read PEM private key done: type DSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: scp -v -t WEBDSP.TXT
Sending file modes: C0777 3894 webdsp.txt
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.8 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0
What do you think?
"Tibor Karaszi" wrote:
> Probably service account and permissions problems. Verify that Agent has the needed permissions.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
> news:0DF4CDB5-4C6A-49AA-A798-4B56DFCDA65D@.microsoft.com...
>
|||> ok thanks for yor answer but the user has permission to run the service,
I don't understand what you mean by above. When agent executes something, it is executed in agents
service user context, not the user who owns the job.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
news:F10E7461-4A0B-49A5-8087-432269318F23@.microsoft.com...[vbcol=seagreen]
> ok thanks for yor answer but the user has permission to run the service, In
> fact the user can run other batch files.
> I debug the batch and this is the result:
> Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command scp -v
> -t WEBDSP.TXT
> OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
> debug1: Reading configuration data /etc/ssh_config
> debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
> debug1: Connection established.
> debug1: identity file id_dsa type 2
> debug1: Remote protocol version 1.99, remote software version OpenSSH_3.7.1p2
> debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
> debug1: Enabling compatibility mode for protocol 2.0
> debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
> debug1: SSH2_MSG_KEXINIT sent
> debug1: SSH2_MSG_KEXINIT received
> debug1: kex: server->client aes128-cbc hmac-md5 none
> debug1: kex: client->server aes128-cbc hmac-md5 none
> debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
> debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
> -- last line --
> This results is when I run from SQL Server, but if a run it from command
> console the result is this
> Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command
> -t WEBDSP.TXT
> OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
> debug1: Reading configuration data /etc/ssh_config
> debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
> debug1: Connection established.
> debug1: identity file id_dsa type 2
> debug1: Remote protocol version 1.99, remote software version OpenSSH_3.
> debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
> debug1: Enabling compatibility mode for protocol 2.0
> debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
> debug1: SSH2_MSG_KEXINIT sent
> debug1: SSH2_MSG_KEXINIT received
> debug1: kex: server->client aes128-cbc hmac-md5 none
> debug1: kex: client->server aes128-cbc hmac-md5 none
> debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
> debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
> debug1: Host '10.10.10.1' is known and matches the RSA host key.
> debug1: Found key in /home/ottod/.ssh/known_hosts:1
> debug1: ssh_rsa_verify: signature correct
> debug1: SSH2_MSG_NEWKEYS sent
> debug1: expecting SSH2_MSG_NEWKEYS
> debug1: SSH2_MSG_NEWKEYS received
> debug1: SSH2_MSG_SERVICE_REQUEST sent
> debug1: SSH2_MSG_SERVICE_ACCEPT received
> debug1: Authentications that can continue: publickey,password,keyboard-i
> ve
> debug1: Next authentication method: publickey
> debug1: Offering public key: id_dsa
> debug1: Server accepts key: pkalg ssh-dss blen 433
> debug1: read PEM private key done: type DSA
> debug1: Authentication succeeded (publickey).
> debug1: channel 0: new [client-session]
> debug1: Entering interactive session.
> debug1: Sending command: scp -v -t WEBDSP.TXT
> Sending file modes: C0777 3894 webdsp.txt
> debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
> debug1: channel 0: free: client-session, nchannels 1
> debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.8 seconds
> debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
> debug1: Exit status 0
>
> What do you think?
> "Tibor Karaszi" wrote:
|||the user can run the agent, because I created others job and run fine
"jdonaldo" wrote:
> I have a Batch file to use ssh connection. So When I run the batch file
> manually its works fine, but when I schedule it on job managment from SQL
> 2000 it doesnt work.
> Help me please
running a batch file
manually its works fine, but when I schedule it on job managment from SQL
2000 it doesnt work.
Help me pleaseProbably service account and permissions problems. Verify that Agent has the
needed permissions.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
news:0DF4CDB5-4C6A-49AA-A798-4B56DFCDA65D@.microsoft.com...
>I have a Batch file to use ssh connection. So When I run the batch file
> manually its works fine, but when I schedule it on job managment from SQL
> 2000 it doesnt work.
> Help me please|||ok thanks for yor answer but the user has permission to run the service, In
fact the user can run other batch files.
I debug the batch and this is the result:
Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command scp -v
-t WEBDSP.TXT
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.7.1p
2
debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
-- last line --
This results is when I run from SQL Server, but if a run it from command
console the result is this
Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command
-t WEBDSP.TXT
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.
debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '10.10.10.1' is known and matches the RSA host key.
debug1: Found key in /home/ottod/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-i
ve
debug1: Next authentication method: publickey
debug1: Offering public key: id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: read PEM private key done: type DSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: scp -v -t WEBDSP.TXT
Sending file modes: C0777 3894 webdsp.txt
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.8 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0
What do you think?
"Tibor Karaszi" wrote:
> Probably service account and permissions problems. Verify that Agent has t
he needed permissions.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
> news:0DF4CDB5-4C6A-49AA-A798-4B56DFCDA65D@.microsoft.com...
>|||> ok thanks for yor answer but the user has permission to run the service,
I don't understand what you mean by above. When agent executes something, it
is executed in agents
service user context, not the user who owns the job.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"jdonaldo" <jdonaldo@.discussions.microsoft.com> wrote in message
news:F10E7461-4A0B-49A5-8087-432269318F23@.microsoft.com...[vbcol=seagreen]
> ok thanks for yor answer but the user has permission to run the service, I
n
> fact the user can run other batch files.
> I debug the batch and this is the result:
> Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command scp -
v
> -t WEBDSP.TXT
> OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
> debug1: Reading configuration data /etc/ssh_config
> debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
> debug1: Connection established.
> debug1: identity file id_dsa type 2
> debug1: Remote protocol version 1.99, remote software version OpenSSH_3.7.
1p2
> debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
> debug1: Enabling compatibility mode for protocol 2.0
> debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
> debug1: SSH2_MSG_KEXINIT sent
> debug1: SSH2_MSG_KEXINIT received
> debug1: kex: server->client aes128-cbc hmac-md5 none
> debug1: kex: client->server aes128-cbc hmac-md5 none
> debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
> debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
> -- last line --
> This results is when I run from SQL Server, but if a run it from command
> console the result is this
> Executing: program /usr/bin/ssh host 10.10.10.1, user dispo, command
> -t WEBDSP.TXT
> OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
> debug1: Reading configuration data /etc/ssh_config
> debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
> debug1: Connection established.
> debug1: identity file id_dsa type 2
> debug1: Remote protocol version 1.99, remote software version OpenSSH_3.
> debug1: match: OpenSSH_3.7.1p2 pat OpenSSH*
> debug1: Enabling compatibility mode for protocol 2.0
> debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
> debug1: SSH2_MSG_KEXINIT sent
> debug1: SSH2_MSG_KEXINIT received
> debug1: kex: server->client aes128-cbc hmac-md5 none
> debug1: kex: client->server aes128-cbc hmac-md5 none
> debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
> debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
> debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
> debug1: Host '10.10.10.1' is known and matches the RSA host key.
> debug1: Found key in /home/ottod/.ssh/known_hosts:1
> debug1: ssh_rsa_verify: signature correct
> debug1: SSH2_MSG_NEWKEYS sent
> debug1: expecting SSH2_MSG_NEWKEYS
> debug1: SSH2_MSG_NEWKEYS received
> debug1: SSH2_MSG_SERVICE_REQUEST sent
> debug1: SSH2_MSG_SERVICE_ACCEPT received
> debug1: Authentications that can continue: publickey,password,keyboard-i
> ve
> debug1: Next authentication method: publickey
> debug1: Offering public key: id_dsa
> debug1: Server accepts key: pkalg ssh-dss blen 433
> debug1: read PEM private key done: type DSA
> debug1: Authentication succeeded (publickey).
> debug1: channel 0: new [client-session]
> debug1: Entering interactive session.
> debug1: Sending command: scp -v -t WEBDSP.TXT
> Sending file modes: C0777 3894 webdsp.txt
> debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
> debug1: channel 0: free: client-session, nchannels 1
> debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.8 seconds
> debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
> debug1: Exit status 0
>
> What do you think?
> "Tibor Karaszi" wrote:
>|||the user can run the agent, because I created others job and run fine
"jdonaldo" wrote:
> I have a Batch file to use ssh connection. So When I run the batch file
> manually its works fine, but when I schedule it on job managment from SQL
> 2000 it doesnt work.
> Help me please
Running a batch command using scheduler
Hi,
I have a batch file that runs an isql script. The sql accepts command line arguments as parameters. I want to invoke this batch file using windows scheduler. How do I pass parameters to my sql? Somebody please help.
Thanks.
I am not sure about the batch file idea, but SQL server has a job scheduler built in called sql agent. You would be much better using this to call a stored procedure and pass in the arguments. To get you started, try this:http://msdn2.microsoft.com/en-us/library(d=robot)/ms189237.aspx
Otherwise, why not replace your batch file with a .NET console application that takes command line parameters and passes them to a stored procedure call. Batch files are old, and while they still have some uses, there are much better ways of achieving what you are trying to do in an easier way, which gives you more power and flexibility.
There is a way to run sql scripts from the commandline using an exe supplied with sql server. For information on this, check out:
http://msdn2.microsoft.com/en-us/library/ms170207.aspx
HTH
For more T-SQL tips, check out my home page:|||Thanks for the reply :)
Friday, March 23, 2012
Running .Sql Files in a batch
I have got multiple .sql files(text files) having T-SQL Statements. I want
to run them all together from query analyzer...how can i do that...
Your help will be appreciatedhI
Let me say you have a file as
Use Pubs
GO
CREATE PROCEDURE spMyProc
AS
SELECT * FROM Titles
--Run this command in QA
EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
"D:\ORD1.sql"'
"kailux4" <kailux4@.discussions.microsoft.com> wrote in message
news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
> Hi,
> I have got multiple .sql files(text files) having T-SQL Statements. I want
> to run them all together from query analyzer...how can i do that...
> Your help will be appreciated|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eS%23FL1oaFHA.2900@.TK2MSFTNGP15.phx.gbl...
> hI
> Let me say you have a file as
> Use Pubs
> GO
> CREATE PROCEDURE spMyProc
> AS
> SELECT * FROM Titles
> --Run this command in QA
> EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
> "D:\ORD1.sql"'
But bear in mind that "D:\" is a drive on the __server__, not on the client.
Regards
Wojtek|||"kailux4" <kailux4@.discussions.microsoft.com> wrote in message
news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
> Hi,
> I have got multiple .sql files(text files) having T-SQL Statements. I want
> to run them all together from query analyzer...how can i do that...
> Your help will be appreciated
Why from QA? Why not write a batch and use isql.exe within?
Regards
Wojtek|||Hi,
I recommend you to run the .SQL files from command prompt using OSQL
redirecting the output to a log file.
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name.sql >
output.log
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name1.sql >>
output.log
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name2.sql >>
output.log
Thanks
Hari
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eS%23FL1oaFHA.2900@.TK2MSFTNGP15.phx.gbl...
> hI
> Let me say you have a file as
> Use Pubs
> GO
> CREATE PROCEDURE spMyProc
> AS
> SELECT * FROM Titles
> --Run this command in QA
> EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
> "D:\ORD1.sql"'
>
> "kailux4" <kailux4@.discussions.microsoft.com> wrote in message
> news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
>> Hi,
>> I have got multiple .sql files(text files) having T-SQL Statements. I
>> want
>> to run them all together from query analyzer...how can i do that...
>> Your help will be appreciated
>
Running .Sql Files in a batch
I have got multiple .sql files(text files) having T-SQL Statements. I want
to run them all together from query analyzer...how can i do that...
Your help will be appreciated
hI
Let me say you have a file as
Use Pubs
GO
CREATE PROCEDURE spMyProc
AS
SELECT * FROM Titles
--Run this command in QA
EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
"D:\ORD1.sql"'
"kailux4" <kailux4@.discussions.microsoft.com> wrote in message
news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
> Hi,
> I have got multiple .sql files(text files) having T-SQL Statements. I want
> to run them all together from query analyzer...how can i do that...
> Your help will be appreciated
|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eS%23FL1oaFHA.2900@.TK2MSFTNGP15.phx.gbl...
> hI
> Let me say you have a file as
> Use Pubs
> GO
> CREATE PROCEDURE spMyProc
> AS
> SELECT * FROM Titles
> --Run this command in QA
> EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
> "D:\ORD1.sql"'
But bear in mind that "D:\" is a drive on the __server__, not on the client.
Regards
Wojtek
|||"kailux4" <kailux4@.discussions.microsoft.com> wrote in message
news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
> Hi,
> I have got multiple .sql files(text files) having T-SQL Statements. I want
> to run them all together from query analyzer...how can i do that...
> Your help will be appreciated
Why from QA? Why not write a batch and use isql.exe within?
Regards
Wojtek
|||Hi,
I recommend you to run the .SQL files from command prompt using OSQL
redirecting the output to a log file.
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name.sql >
output.log
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name1.sql >>
output.log
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name2.sql >>
output.log
Thanks
Hari
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eS%23FL1oaFHA.2900@.TK2MSFTNGP15.phx.gbl...
> hI
> Let me say you have a file as
> Use Pubs
> GO
> CREATE PROCEDURE spMyProc
> AS
> SELECT * FROM Titles
> --Run this command in QA
> EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
> "D:\ORD1.sql"'
>
> "kailux4" <kailux4@.discussions.microsoft.com> wrote in message
> news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
>
sql
Running .Sql Files in a batch
I have got multiple .sql files(text files) having T-SQL Statements. I want
to run them all together from query analyzer...how can i do that...
Your help will be appreciatedhI
Let me say you have a file as
Use Pubs
GO
CREATE PROCEDURE spMyProc
AS
SELECT * FROM Titles
--Run this command in QA
EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
"D:\ORD1.sql"'
"kailux4" <kailux4@.discussions.microsoft.com> wrote in message
news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
> Hi,
> I have got multiple .sql files(text files) having T-SQL Statements. I want
> to run them all together from query analyzer...how can i do that...
> Your help will be appreciated|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eS%23FL1oaFHA.2900@.TK2MSFTNGP15.phx.gbl...
> hI
> Let me say you have a file as
> Use Pubs
> GO
> CREATE PROCEDURE spMyProc
> AS
> SELECT * FROM Titles
> --Run this command in QA
> EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
> "D:\ORD1.sql"'
But bear in mind that "D:\" is a drive on the __server__, not on the client.
Regards
Wojtek|||"kailux4" <kailux4@.discussions.microsoft.com> wrote in message
news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
> Hi,
> I have got multiple .sql files(text files) having T-SQL Statements. I want
> to run them all together from query analyzer...how can i do that...
> Your help will be appreciated
Why from QA? Why not write a batch and use isql.exe within?
Regards
Wojtek|||Hi,
I recommend you to run the .SQL files from command prompt using OSQL
redirecting the output to a log file.
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name.sql >
output.log
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name1.sql >>
output.log
OSQL -SSERVER_NAME -Uuser -Ppassword -d db_name -i file_name2.sql >>
output.log
Thanks
Hari
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eS%23FL1oaFHA.2900@.TK2MSFTNGP15.phx.gbl...
> hI
> Let me say you have a file as
> Use Pubs
> GO
> CREATE PROCEDURE spMyProc
> AS
> SELECT * FROM Titles
> --Run this command in QA
> EXEC master..xp_cmdshell 'osql.exe -S SERVERNAME -U sa -P pass -i
> "D:\ORD1.sql"'
>
> "kailux4" <kailux4@.discussions.microsoft.com> wrote in message
> news:067CC39F-41E2-4170-B132-927FDB458C9C@.microsoft.com...
>
Friday, March 9, 2012
Run Batch Files with SQL Server Agent
I am trying to run a batch file using the SQL Server Agent
(I have scheduled a job). I have chosen the step type to
be 'Operating System Command (CmdExec)'. But I am not sure
how to code the actual command.
The batch file is located at: e:\sqlbackups\delete.bat.
How do specify the Agent to call this batch file?
Thanks,
DeeJayHi,
In SQL Agent Jobs -- Step option, after selecting 'Operating System Command
(CmdExec)' , In the command window you can type
e:\sqlbackups\delete.bat
(This will call the batch file delete.bat based on the schedule interval)
Thanks
Hari
MCDBA
"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
news:14f3201c3fa33$599d4120$a001280a@.phx
.gbl...
> Hi,
> I am trying to run a batch file using the SQL Server Agent
> (I have scheduled a job). I have chosen the step type to
> be 'Operating System Command (CmdExec)'. But I am not sure
> how to code the actual command.
> The batch file is located at: e:\sqlbackups\delete.bat.
> How do specify the Agent to call this batch file?
> Thanks,
> DeeJay
>|||Hi
Thanks, but that's exactly how I have been trying to run
it, but it does not work.
I am running the job with an administrative account that
has the required permissions.
I have tested the script by running is manually on the
server and it works fine.
I wonder what gives.
DeeJay
>--Original Message--
>Hi,
>In SQL Agent Jobs -- Step option, after
selecting 'Operating System Command
>(CmdExec)' , In the command window you can type
>e:\sqlbackups\delete.bat
>(This will call the batch file delete.bat based on the
schedule interval)
>Thanks
>Hari
>MCDBA
>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
> news:14f3201c3fa33$599d4120$a001280a@.phx
.gbl...
Agent
sure
>
>.
>|||Do you get any error message, what happens when you try to
run the job ?
How long the batch file takes to run ? We had an issue
where sql agent timed out if the batch file took more than
30 minutes to run. It happened only once and we ran the
file manually from command prompt. You can also try to run
it as a tsql command using Exec
master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
hth.
>--Original Message--
>Hi
>Thanks, but that's exactly how I have been trying to run
>it, but it does not work.
>I am running the job with an administrative account that
>has the required permissions.
>I have tested the script by running is manually on the
>server and it works fine.
>I wonder what gives.
>DeeJay
>selecting 'Operating System Command
>schedule interval)
>Agent
to
>sure
>.
>|||That's the weird part...I do not get any errors. Actually
according to the agent the job completes successfully, but
the files are not deleted.
I tried your suggestion and it did not work. But this time
I do get an error:
The process could not be created for step 1 of job
0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped I/O
operation is in progress). The step failed.
This is really confusing. I do not want to run the
manually every other day.
Thanks,
DeeJay
>--Original Message--
>Do you get any error message, what happens when you try
to
>run the job ?
>How long the batch file takes to run ? We had an issue
>where sql agent timed out if the batch file took more
than
>30 minutes to run. It happened only once and we ran the
>file manually from command prompt. You can also try to
run
>it as a tsql command using Exec
>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>hth.
>
>to
e:\sqlbackups\delete.bat.
>.
>|||For real time error info, try to execute xp_cmdshell from
query analyzer.
I wonder if it is a permission issue, if the job owner is
a sysadmin then then sql server will use service startup
account to execute xp_cmdshell, otherwise it will use a
proxy account. Does sql startup account has permissions to
delete those files ?
hth.
>--Original Message--
>That's the weird part...I do not get any errors. Actually
>according to the agent the job completes successfully,
but
>the files are not deleted.
>I tried your suggestion and it did not work. But this
time
>I do get an error:
>The process could not be created for step 1 of job
>0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped
I/O
>operation is in progress). The step failed.
>This is really confusing. I do not want to run the
>manually every other day.
>Thanks,
>DeeJay
>
>to
>than
>run
run
that
type
not
>e:\sqlbackups\delete.bat.
>.
>|||I tested running the job with me as the owner and I am a
local administrator on this server. I have also tried
using 'sa' and the service startup and nothing is working.
I have tried running the xp_cmdshell procedure in QA and
it also does not work...I just get the output as 'NULL'.
I wonder if it is ONLY using the proxy account. That
account may not have the required permissions.
I will check that.
DeeJay
>--Original Message--
>For real time error info, try to execute xp_cmdshell from
>query analyzer.
>I wonder if it is a permission issue, if the job owner is
>a sysadmin then then sql server will use service startup
>account to execute xp_cmdshell, otherwise it will use a
>proxy account. Does sql startup account has permissions
to
>delete those files ?
>hth.
>
Actually
>but
>time
>I/O
>run
>that
the
Server
>type
>not
>.
>|||Hi,
I forgot that SQL Server 2000 does not have this proxy
account on the local server. I did find a domain
account 'SQLServerAcctCmdExec' and I added this to the
local administrators account and it still did not work.
DeeJay
>--Original Message--
>I tested running the job with me as the owner and I am a
>local administrator on this server. I have also tried
>using 'sa' and the service startup and nothing is working.
>I have tried running the xp_cmdshell procedure in QA and
>it also does not work...I just get the output as 'NULL'.
>I wonder if it is ONLY using the proxy account. That
>account may not have the required permissions.
>I will check that.
>DeeJay
from
is
>to
>Actually
try
the
the
>the
>Server
>.
>|||Make a little change to the batch file and add folloiwng
line at different places:
@.echo In the batch file at line <#>
when you run the batch file in QA it should display these
messages in results window.
In Enterprise Manager, if you open properties of SQL
Server Agent, click on Job System, you will see option to
specify proxy account, use a local admin for it, and then
restart sql services.
hope this helps.
>--Original Message--
>Hi,
>I forgot that SQL Server 2000 does not have this proxy
>account on the local server. I did find a domain
>account 'SQLServerAcctCmdExec' and I added this to the
>local administrators account and it still did not work.
>DeeJay
working.
>from
>is
startup
>try
issue
>the
to
>the
message
>.
>|||I made the change and the script did not return all of the
expected lines. The scripts is doing a 'for' loop so that
could be the reason for not returning all of the lines.
I tried to enter the proxy account, but I am getting
errors:
'Error executing extended stored procedure: Specified User
can not login'.
I am connected to SQL Server with 'sa' and I tried the
local administrator account (will it be a problem if the
local administrator account has been renamed?) and I also
tried with my own domain ID (sysadmin on sql server) and
same results. I did not think I would need change the
account since 'only sysadmins' can run cmdshell jobs and I
have been trying to run the jobs/commands with sysadmin
rights.
Here is the actual script which works fine manually on the
server:
@.echo off
setlocal
:: *** Root path of the directory where the files are to
be deleted:
set
Root=E:\sqlbackups\archtlog\CopyArchdTlo
gBackups\kdirect
:: *** Number of files to keep:
set Keep=590
if not exist "%Root%" goto :err_Root
for /f "skip=%Keep% tokens=*" %%a in ('dir /b /a:-d /o:-
d "%Root%" 2^>NUL') do (
echo Deleting %%a ...
:: *** Remove the "echo" in the next line to 'arm' the
script:
del "%Root%\%%a"
)
goto leave
:err_Root
echo The directory "%Root%" does not exist.
:leave
This is really bugging me!
DeeJay
>--Original Message--
>Make a little change to the batch file and add folloiwng
>line at different places:
>@.echo In the batch file at line <#>
>when you run the batch file in QA it should display these
>messages in results window.
>In Enterprise Manager, if you open properties of SQL
>Server Agent, click on Job System, you will see option to
>specify proxy account, use a local admin for it, and then
>restart sql services.
>hope this helps.
>
a
>working.
and
as 'NULL'.
>startup
a
permissions
successfully,
Overlapped
>issue
more
>to
to
>message
am
>.
>
Run Batch Files with SQL Server Agent
I am trying to run a batch file using the SQL Server Agent
(I have scheduled a job). I have chosen the step type to
be 'Operating System Command (CmdExec)'. But I am not sure
how to code the actual command.
The batch file is located at: e:\sqlbackups\delete.bat.
How do specify the Agent to call this batch file?
Thanks,
DeeJayHi,
In SQL Agent Jobs -- Step option, after selecting 'Operating System Command
(CmdExec)' , In the command window you can type
e:\sqlbackups\delete.bat
(This will call the batch file delete.bat based on the schedule interval)
Thanks
Hari
MCDBA
"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
> Hi,
> I am trying to run a batch file using the SQL Server Agent
> (I have scheduled a job). I have chosen the step type to
> be 'Operating System Command (CmdExec)'. But I am not sure
> how to code the actual command.
> The batch file is located at: e:\sqlbackups\delete.bat.
> How do specify the Agent to call this batch file?
> Thanks,
> DeeJay
>|||Hi
Thanks, but that's exactly how I have been trying to run
it, but it does not work.
I am running the job with an administrative account that
has the required permissions.
I have tested the script by running is manually on the
server and it works fine.
I wonder what gives.
DeeJay
>--Original Message--
>Hi,
>In SQL Agent Jobs -- Step option, after
selecting 'Operating System Command
>(CmdExec)' , In the command window you can type
>e:\sqlbackups\delete.bat
>(This will call the batch file delete.bat based on the
schedule interval)
>Thanks
>Hari
>MCDBA
>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>> Hi,
>> I am trying to run a batch file using the SQL Server
Agent
>> (I have scheduled a job). I have chosen the step type to
>> be 'Operating System Command (CmdExec)'. But I am not
sure
>> how to code the actual command.
>> The batch file is located at: e:\sqlbackups\delete.bat.
>> How do specify the Agent to call this batch file?
>> Thanks,
>> DeeJay
>
>.
>|||Do you get any error message, what happens when you try to
run the job ?
How long the batch file takes to run ? We had an issue
where sql agent timed out if the batch file took more than
30 minutes to run. It happened only once and we ran the
file manually from command prompt. You can also try to run
it as a tsql command using Exec
master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
hth.
>--Original Message--
>Hi
>Thanks, but that's exactly how I have been trying to run
>it, but it does not work.
>I am running the job with an administrative account that
>has the required permissions.
>I have tested the script by running is manually on the
>server and it works fine.
>I wonder what gives.
>DeeJay
>>--Original Message--
>>Hi,
>>In SQL Agent Jobs -- Step option, after
>selecting 'Operating System Command
>>(CmdExec)' , In the command window you can type
>>e:\sqlbackups\delete.bat
>>(This will call the batch file delete.bat based on the
>schedule interval)
>>Thanks
>>Hari
>>MCDBA
>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>> Hi,
>> I am trying to run a batch file using the SQL Server
>Agent
>> (I have scheduled a job). I have chosen the step type
to
>> be 'Operating System Command (CmdExec)'. But I am not
>sure
>> how to code the actual command.
>> The batch file is located at: e:\sqlbackups\delete.bat.
>> How do specify the Agent to call this batch file?
>> Thanks,
>> DeeJay
>>
>>.
>.
>|||That's the weird part...I do not get any errors. Actually
according to the agent the job completes successfully, but
the files are not deleted.
I tried your suggestion and it did not work. But this time
I do get an error:
The process could not be created for step 1 of job
0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped I/O
operation is in progress). The step failed.
This is really confusing. I do not want to run the
manually every other day.
Thanks,
DeeJay
>--Original Message--
>Do you get any error message, what happens when you try
to
>run the job ?
>How long the batch file takes to run ? We had an issue
>where sql agent timed out if the batch file took more
than
>30 minutes to run. It happened only once and we ran the
>file manually from command prompt. You can also try to
run
>it as a tsql command using Exec
>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>hth.
>>--Original Message--
>>Hi
>>Thanks, but that's exactly how I have been trying to run
>>it, but it does not work.
>>I am running the job with an administrative account that
>>has the required permissions.
>>I have tested the script by running is manually on the
>>server and it works fine.
>>I wonder what gives.
>>DeeJay
>>--Original Message--
>>Hi,
>>In SQL Agent Jobs -- Step option, after
>>selecting 'Operating System Command
>>(CmdExec)' , In the command window you can type
>>e:\sqlbackups\delete.bat
>>(This will call the batch file delete.bat based on the
>>schedule interval)
>>Thanks
>>Hari
>>MCDBA
>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>> Hi,
>> I am trying to run a batch file using the SQL Server
>>Agent
>> (I have scheduled a job). I have chosen the step type
>to
>> be 'Operating System Command (CmdExec)'. But I am not
>>sure
>> how to code the actual command.
>> The batch file is located at:
e:\sqlbackups\delete.bat.
>> How do specify the Agent to call this batch file?
>> Thanks,
>> DeeJay
>>
>>.
>>.
>.
>|||For real time error info, try to execute xp_cmdshell from
query analyzer.
I wonder if it is a permission issue, if the job owner is
a sysadmin then then sql server will use service startup
account to execute xp_cmdshell, otherwise it will use a
proxy account. Does sql startup account has permissions to
delete those files ?
hth.
>--Original Message--
>That's the weird part...I do not get any errors. Actually
>according to the agent the job completes successfully,
but
>the files are not deleted.
>I tried your suggestion and it did not work. But this
time
>I do get an error:
>The process could not be created for step 1 of job
>0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped
I/O
>operation is in progress). The step failed.
>This is really confusing. I do not want to run the
>manually every other day.
>Thanks,
>DeeJay
>>--Original Message--
>>Do you get any error message, what happens when you try
>to
>>run the job ?
>>How long the batch file takes to run ? We had an issue
>>where sql agent timed out if the batch file took more
>than
>>30 minutes to run. It happened only once and we ran the
>>file manually from command prompt. You can also try to
>run
>>it as a tsql command using Exec
>>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>>hth.
>>--Original Message--
>>Hi
>>Thanks, but that's exactly how I have been trying to
run
>>it, but it does not work.
>>I am running the job with an administrative account
that
>>has the required permissions.
>>I have tested the script by running is manually on the
>>server and it works fine.
>>I wonder what gives.
>>DeeJay
>>--Original Message--
>>Hi,
>>In SQL Agent Jobs -- Step option, after
>>selecting 'Operating System Command
>>(CmdExec)' , In the command window you can type
>>e:\sqlbackups\delete.bat
>>(This will call the batch file delete.bat based on the
>>schedule interval)
>>Thanks
>>Hari
>>MCDBA
>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>> Hi,
>> I am trying to run a batch file using the SQL Server
>>Agent
>> (I have scheduled a job). I have chosen the step
type
>>to
>> be 'Operating System Command (CmdExec)'. But I am
not
>>sure
>> how to code the actual command.
>> The batch file is located at:
>e:\sqlbackups\delete.bat.
>> How do specify the Agent to call this batch file?
>> Thanks,
>> DeeJay
>>
>>.
>>.
>>.
>.
>|||I tested running the job with me as the owner and I am a
local administrator on this server. I have also tried
using 'sa' and the service startup and nothing is working.
I have tried running the xp_cmdshell procedure in QA and
it also does not work...I just get the output as 'NULL'.
I wonder if it is ONLY using the proxy account. That
account may not have the required permissions.
I will check that.
DeeJay
>--Original Message--
>For real time error info, try to execute xp_cmdshell from
>query analyzer.
>I wonder if it is a permission issue, if the job owner is
>a sysadmin then then sql server will use service startup
>account to execute xp_cmdshell, otherwise it will use a
>proxy account. Does sql startup account has permissions
to
>delete those files ?
>hth.
>>--Original Message--
>>That's the weird part...I do not get any errors.
Actually
>>according to the agent the job completes successfully,
>but
>>the files are not deleted.
>>I tried your suggestion and it did not work. But this
>time
>>I do get an error:
>>The process could not be created for step 1 of job
>>0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped
>I/O
>>operation is in progress). The step failed.
>>This is really confusing. I do not want to run the
>>manually every other day.
>>Thanks,
>>DeeJay
>>--Original Message--
>>Do you get any error message, what happens when you try
>>to
>>run the job ?
>>How long the batch file takes to run ? We had an issue
>>where sql agent timed out if the batch file took more
>>than
>>30 minutes to run. It happened only once and we ran the
>>file manually from command prompt. You can also try to
>>run
>>it as a tsql command using Exec
>>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>>hth.
>>--Original Message--
>>Hi
>>Thanks, but that's exactly how I have been trying to
>run
>>it, but it does not work.
>>I am running the job with an administrative account
>that
>>has the required permissions.
>>I have tested the script by running is manually on the
>>server and it works fine.
>>I wonder what gives.
>>DeeJay
>>--Original Message--
>>Hi,
>>In SQL Agent Jobs -- Step option, after
>>selecting 'Operating System Command
>>(CmdExec)' , In the command window you can type
>>e:\sqlbackups\delete.bat
>>(This will call the batch file delete.bat based on
the
>>schedule interval)
>>Thanks
>>Hari
>>MCDBA
>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>> Hi,
>> I am trying to run a batch file using the SQL
Server
>>Agent
>> (I have scheduled a job). I have chosen the step
>type
>>to
>> be 'Operating System Command (CmdExec)'. But I am
>not
>>sure
>> how to code the actual command.
>> The batch file is located at:
>>e:\sqlbackups\delete.bat.
>> How do specify the Agent to call this batch file?
>> Thanks,
>> DeeJay
>>
>>.
>>.
>>.
>>.
>.
>|||Hi,
I forgot that SQL Server 2000 does not have this proxy
account on the local server. I did find a domain
account 'SQLServerAcctCmdExec' and I added this to the
local administrators account and it still did not work.
DeeJay
>--Original Message--
>I tested running the job with me as the owner and I am a
>local administrator on this server. I have also tried
>using 'sa' and the service startup and nothing is working.
>I have tried running the xp_cmdshell procedure in QA and
>it also does not work...I just get the output as 'NULL'.
>I wonder if it is ONLY using the proxy account. That
>account may not have the required permissions.
>I will check that.
>DeeJay
>>--Original Message--
>>For real time error info, try to execute xp_cmdshell
from
>>query analyzer.
>>I wonder if it is a permission issue, if the job owner
is
>>a sysadmin then then sql server will use service startup
>>account to execute xp_cmdshell, otherwise it will use a
>>proxy account. Does sql startup account has permissions
>to
>>delete those files ?
>>hth.
>>--Original Message--
>>That's the weird part...I do not get any errors.
>Actually
>>according to the agent the job completes successfully,
>>but
>>the files are not deleted.
>>I tried your suggestion and it did not work. But this
>>time
>>I do get an error:
>>The process could not be created for step 1 of job
>>0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped
>>I/O
>>operation is in progress). The step failed.
>>This is really confusing. I do not want to run the
>>manually every other day.
>>Thanks,
>>DeeJay
>>--Original Message--
>>Do you get any error message, what happens when you
try
>>to
>>run the job ?
>>How long the batch file takes to run ? We had an issue
>>where sql agent timed out if the batch file took more
>>than
>>30 minutes to run. It happened only once and we ran
the
>>file manually from command prompt. You can also try to
>>run
>>it as a tsql command using Exec
>>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>>hth.
>>--Original Message--
>>Hi
>>Thanks, but that's exactly how I have been trying to
>>run
>>it, but it does not work.
>>I am running the job with an administrative account
>>that
>>has the required permissions.
>>I have tested the script by running is manually on
the
>>server and it works fine.
>>I wonder what gives.
>>DeeJay
>>--Original Message--
>>Hi,
>>In SQL Agent Jobs -- Step option, after
>>selecting 'Operating System Command
>>(CmdExec)' , In the command window you can type
>>e:\sqlbackups\delete.bat
>>(This will call the batch file delete.bat based on
>the
>>schedule interval)
>>Thanks
>>Hari
>>MCDBA
>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>>> Hi,
>>>
>>> I am trying to run a batch file using the SQL
>Server
>>Agent
>>> (I have scheduled a job). I have chosen the step
>>type
>>to
>>> be 'Operating System Command (CmdExec)'. But I am
>>not
>>sure
>>> how to code the actual command.
>>>
>>> The batch file is located at:
>>e:\sqlbackups\delete.bat.
>>>
>>> How do specify the Agent to call this batch file?
>>>
>>> Thanks,
>>>
>>> DeeJay
>>>
>>
>>.
>>.
>>.
>>.
>>.
>.
>|||Make a little change to the batch file and add folloiwng
line at different places:
@.echo In the batch file at line <#>
when you run the batch file in QA it should display these
messages in results window.
In Enterprise Manager, if you open properties of SQL
Server Agent, click on Job System, you will see option to
specify proxy account, use a local admin for it, and then
restart sql services.
hope this helps.
>--Original Message--
>Hi,
>I forgot that SQL Server 2000 does not have this proxy
>account on the local server. I did find a domain
>account 'SQLServerAcctCmdExec' and I added this to the
>local administrators account and it still did not work.
>DeeJay
>>--Original Message--
>>I tested running the job with me as the owner and I am a
>>local administrator on this server. I have also tried
>>using 'sa' and the service startup and nothing is
working.
>>I have tried running the xp_cmdshell procedure in QA and
>>it also does not work...I just get the output as 'NULL'.
>>I wonder if it is ONLY using the proxy account. That
>>account may not have the required permissions.
>>I will check that.
>>DeeJay
>>--Original Message--
>>For real time error info, try to execute xp_cmdshell
>from
>>query analyzer.
>>I wonder if it is a permission issue, if the job owner
>is
>>a sysadmin then then sql server will use service
startup
>>account to execute xp_cmdshell, otherwise it will use a
>>proxy account. Does sql startup account has permissions
>>to
>>delete those files ?
>>hth.
>>--Original Message--
>>That's the weird part...I do not get any errors.
>>Actually
>>according to the agent the job completes successfully,
>>but
>>the files are not deleted.
>>I tried your suggestion and it did not work. But this
>>time
>>I do get an error:
>>The process could not be created for step 1 of job
>>0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped
>>I/O
>>operation is in progress). The step failed.
>>This is really confusing. I do not want to run the
>>manually every other day.
>>Thanks,
>>DeeJay
>>--Original Message--
>>Do you get any error message, what happens when you
>try
>>to
>>run the job ?
>>How long the batch file takes to run ? We had an
issue
>>where sql agent timed out if the batch file took more
>>than
>>30 minutes to run. It happened only once and we ran
>the
>>file manually from command prompt. You can also try
to
>>run
>>it as a tsql command using Exec
>>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>>hth.
>>--Original Message--
>>Hi
>>Thanks, but that's exactly how I have been trying to
>>run
>>it, but it does not work.
>>I am running the job with an administrative account
>>that
>>has the required permissions.
>>I have tested the script by running is manually on
>the
>>server and it works fine.
>>I wonder what gives.
>>DeeJay
>>>--Original Message--
>>>Hi,
>>>
>>>In SQL Agent Jobs -- Step option, after
>>selecting 'Operating System Command
>>>(CmdExec)' , In the command window you can type
>>>
>>>e:\sqlbackups\delete.bat
>>>
>>>(This will call the batch file delete.bat based on
>>the
>>schedule interval)
>>>
>>>Thanks
>>>Hari
>>>MCDBA
>>>
>>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in
message
>>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>>> Hi,
>>>
>>> I am trying to run a batch file using the SQL
>>Server
>>Agent
>>> (I have scheduled a job). I have chosen the step
>>type
>>to
>>> be 'Operating System Command (CmdExec)'. But I am
>>not
>>sure
>>> how to code the actual command.
>>>
>>> The batch file is located at:
>>e:\sqlbackups\delete.bat.
>>>
>>> How do specify the Agent to call this batch file?
>>>
>>> Thanks,
>>>
>>> DeeJay
>>>
>>>
>>>
>>>.
>>>
>>.
>>.
>>.
>>.
>>.
>.
>|||I made the change and the script did not return all of the
expected lines. The scripts is doing a 'for' loop so that
could be the reason for not returning all of the lines.
I tried to enter the proxy account, but I am getting
errors:
'Error executing extended stored procedure: Specified User
can not login'.
I am connected to SQL Server with 'sa' and I tried the
local administrator account (will it be a problem if the
local administrator account has been renamed?) and I also
tried with my own domain ID (sysadmin on sql server) and
same results. I did not think I would need change the
account since 'only sysadmins' can run cmdshell jobs and I
have been trying to run the jobs/commands with sysadmin
rights.
Here is the actual script which works fine manually on the
server:
@.echo off
setlocal
:: *** Root path of the directory where the files are to
be deleted:
set
Root=E:\sqlbackups\archtlog\CopyArchdTlogBackups\kdirect
:: *** Number of files to keep:
set Keep=590
if not exist "%Root%" goto :err_Root
for /f "skip=%Keep% tokens=*" %%a in ('dir /b /a:-d /o:-
d "%Root%" 2^>NUL') do (
echo Deleting %%a ...
:: *** Remove the "echo" in the next line to 'arm' the
script:
del "%Root%\%%a"
)
goto leave
:err_Root
echo The directory "%Root%" does not exist.
:leave
This is really bugging me!
DeeJay
>--Original Message--
>Make a little change to the batch file and add folloiwng
>line at different places:
>@.echo In the batch file at line <#>
>when you run the batch file in QA it should display these
>messages in results window.
>In Enterprise Manager, if you open properties of SQL
>Server Agent, click on Job System, you will see option to
>specify proxy account, use a local admin for it, and then
>restart sql services.
>hope this helps.
>>--Original Message--
>>Hi,
>>I forgot that SQL Server 2000 does not have this proxy
>>account on the local server. I did find a domain
>>account 'SQLServerAcctCmdExec' and I added this to the
>>local administrators account and it still did not work.
>>DeeJay
>>--Original Message--
>>I tested running the job with me as the owner and I am
a
>>local administrator on this server. I have also tried
>>using 'sa' and the service startup and nothing is
>working.
>>I have tried running the xp_cmdshell procedure in QA
and
>>it also does not work...I just get the output
as 'NULL'.
>>I wonder if it is ONLY using the proxy account. That
>>account may not have the required permissions.
>>I will check that.
>>DeeJay
>>--Original Message--
>>For real time error info, try to execute xp_cmdshell
>>from
>>query analyzer.
>>I wonder if it is a permission issue, if the job owner
>>is
>>a sysadmin then then sql server will use service
>startup
>>account to execute xp_cmdshell, otherwise it will use
a
>>proxy account. Does sql startup account has
permissions
>>to
>>delete those files ?
>>hth.
>>--Original Message--
>>That's the weird part...I do not get any errors.
>>Actually
>>according to the agent the job completes
successfully,
>>but
>>the files are not deleted.
>>I tried your suggestion and it did not work. But this
>>time
>>I do get an error:
>>The process could not be created for step 1 of job
>>0xC38683087ECAA14AB6614A1A74F27555 (reason:
Overlapped
>>I/O
>>operation is in progress). The step failed.
>>This is really confusing. I do not want to run the
>>manually every other day.
>>Thanks,
>>DeeJay
>>--Original Message--
>>Do you get any error message, what happens when you
>>try
>>to
>>run the job ?
>>How long the batch file takes to run ? We had an
>issue
>>where sql agent timed out if the batch file took
more
>>than
>>30 minutes to run. It happened only once and we ran
>>the
>>file manually from command prompt. You can also try
>to
>>run
>>it as a tsql command using Exec
>>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>>hth.
>>>--Original Message--
>>>Hi
>>>
>>>Thanks, but that's exactly how I have been trying
to
>>run
>>>it, but it does not work.
>>>
>>>I am running the job with an administrative account
>>that
>>>has the required permissions.
>>>
>>>I have tested the script by running is manually on
>>the
>>>server and it works fine.
>>>
>>>I wonder what gives.
>>>
>>>DeeJay
>>>--Original Message--
>>>Hi,
>>>
>>>In SQL Agent Jobs -- Step option, after
>>>selecting 'Operating System Command
>>>(CmdExec)' , In the command window you can type
>>>
>>>e:\sqlbackups\delete.bat
>>>
>>>(This will call the batch file delete.bat based on
>>the
>>>schedule interval)
>>>
>>>Thanks
>>>Hari
>>>MCDBA
>>>
>>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in
>message
>>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
>>> Hi,
>>>
>>> I am trying to run a batch file using the SQL
>>Server
>>>Agent
>>> (I have scheduled a job). I have chosen the step
>>type
>>to
>>> be 'Operating System Command (CmdExec)'. But I
am
>>not
>>>sure
>>> how to code the actual command.
>>>
>>> The batch file is located at:
>>e:\sqlbackups\delete.bat.
>>>
>>> How do specify the Agent to call this batch file?
>>>
>>> Thanks,
>>>
>>> DeeJay
>>>
>>>
>>>
>>>.
>>>
>>>.
>>>
>>.
>>.
>>.
>>.
>>.
>.
>|||Hi Deejay,
2 things,
if you have set up SQL Agent to use proxy account, proxy account will only
be used if the owner of the SQLAgentJob is NOT a member of the local
administrators group.
Secondly if the SQLProxyaccount is a member of the local administrator but
Builtin\Admin has been removed as a part of the a security policy then you
need to add SQLProxy account as a login and grant this account the necessary
rights to execute xp_cmdshell.
I hope this helps your situation.
--
Olu Adedeji
"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in message
news:295d01c3fca7$4b3ddfb0$a501280a@.phx.gbl...
> I made the change and the script did not return all of the
> expected lines. The scripts is doing a 'for' loop so that
> could be the reason for not returning all of the lines.
> I tried to enter the proxy account, but I am getting
> errors:
> 'Error executing extended stored procedure: Specified User
> can not login'.
> I am connected to SQL Server with 'sa' and I tried the
> local administrator account (will it be a problem if the
> local administrator account has been renamed?) and I also
> tried with my own domain ID (sysadmin on sql server) and
> same results. I did not think I would need change the
> account since 'only sysadmins' can run cmdshell jobs and I
> have been trying to run the jobs/commands with sysadmin
> rights.
> Here is the actual script which works fine manually on the
> server:
> @.echo off
> setlocal
> :: *** Root path of the directory where the files are to
> be deleted:
> set
> Root=E:\sqlbackups\archtlog\CopyArchdTlogBackups\kdirect
> :: *** Number of files to keep:
> set Keep=590
>
> if not exist "%Root%" goto :err_Root
> for /f "skip=%Keep% tokens=*" %%a in ('dir /b /a:-d /o:-
> d "%Root%" 2^>NUL') do (
> echo Deleting %%a ...
> :: *** Remove the "echo" in the next line to 'arm' the
> script:
> del "%Root%\%%a"
> )
> goto leave
>
> :err_Root
> echo The directory "%Root%" does not exist.
>
> :leave
>
> This is really bugging me!
> DeeJay
> >--Original Message--
> >Make a little change to the batch file and add folloiwng
> >line at different places:
> >
> >@.echo In the batch file at line <#>
> >
> >when you run the batch file in QA it should display these
> >messages in results window.
> >
> >In Enterprise Manager, if you open properties of SQL
> >Server Agent, click on Job System, you will see option to
> >specify proxy account, use a local admin for it, and then
> >restart sql services.
> >
> >hope this helps.
> >
> >>--Original Message--
> >>Hi,
> >>
> >>I forgot that SQL Server 2000 does not have this proxy
> >>account on the local server. I did find a domain
> >>account 'SQLServerAcctCmdExec' and I added this to the
> >>local administrators account and it still did not work.
> >>
> >>DeeJay
> >>--Original Message--
> >>I tested running the job with me as the owner and I am
> a
> >>local administrator on this server. I have also tried
> >>using 'sa' and the service startup and nothing is
> >working.
> >>
> >>I have tried running the xp_cmdshell procedure in QA
> and
> >>it also does not work...I just get the output
> as 'NULL'.
> >>
> >>I wonder if it is ONLY using the proxy account. That
> >>account may not have the required permissions.
> >>
> >>I will check that.
> >>
> >>DeeJay
> >>--Original Message--
> >>For real time error info, try to execute xp_cmdshell
> >>from
> >>query analyzer.
> >>
> >>I wonder if it is a permission issue, if the job owner
> >>is
> >>a sysadmin then then sql server will use service
> >startup
> >>account to execute xp_cmdshell, otherwise it will use
> a
> >>proxy account. Does sql startup account has
> permissions
> >>to
> >>delete those files ?
> >>
> >>hth.
> >>
> >>--Original Message--
> >>That's the weird part...I do not get any errors.
> >>Actually
> >>according to the agent the job completes
> successfully,
> >>but
> >>the files are not deleted.
> >>
> >>I tried your suggestion and it did not work. But this
> >>time
> >>I do get an error:
> >>
> >>The process could not be created for step 1 of job
> >>0xC38683087ECAA14AB6614A1A74F27555 (reason:
> Overlapped
> >>I/O
> >>operation is in progress). The step failed.
> >>
> >>This is really confusing. I do not want to run the
> >>manually every other day.
> >>
> >>Thanks,
> >>DeeJay
> >>
> >>--Original Message--
> >>Do you get any error message, what happens when you
> >>try
> >>to
> >>run the job ?
> >>
> >>How long the batch file takes to run ? We had an
> >issue
> >>where sql agent timed out if the batch file took
> more
> >>than
> >>30 minutes to run. It happened only once and we ran
> >>the
> >>file manually from command prompt. You can also try
> >to
> >>run
> >>it as a tsql command using Exec
> >>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
> >>
> >>hth.
> >>
> >>>--Original Message--
> >>>Hi
> >>>
> >>>Thanks, but that's exactly how I have been trying
> to
> >>run
> >>>it, but it does not work.
> >>>
> >>>I am running the job with an administrative account
> >>that
> >>>has the required permissions.
> >>>
> >>>I have tested the script by running is manually on
> >>the
> >>>server and it works fine.
> >>>
> >>>I wonder what gives.
> >>>
> >>>DeeJay
> >>>--Original Message--
> >>>Hi,
> >>>
> >>>In SQL Agent Jobs -- Step option, after
> >>>selecting 'Operating System Command
> >>>(CmdExec)' , In the command window you can type
> >>>
> >>>e:\sqlbackups\delete.bat
> >>>
> >>>(This will call the batch file delete.bat based on
> >>the
> >>>schedule interval)
> >>>
> >>>Thanks
> >>>Hari
> >>>MCDBA
> >>>
> >>>"DeeJay Puar" <deejaypuar@.yahoo.com> wrote in
> >message
> >>>news:14f3201c3fa33$599d4120$a001280a@.phx.gbl...
> >>> Hi,
> >>>
> >>> I am trying to run a batch file using the SQL
> >>Server
> >>>Agent
> >>> (I have scheduled a job). I have chosen the step
> >>type
> >>to
> >>> be 'Operating System Command (CmdExec)'. But I
> am
> >>not
> >>>sure
> >>> how to code the actual command.
> >>>
> >>> The batch file is located at:
> >>e:\sqlbackups\delete.bat.
> >>>
> >>> How do specify the Agent to call this batch file?
> >>>
> >>> Thanks,
> >>>
> >>> DeeJay
> >>>
> >>>
> >>>
> >>>.
> >>>
> >>>.
> >>>
> >>.
> >>
> >>.
> >>
> >>.
> >>
> >>.
> >>
> >>.
> >>
> >.
> >
Wednesday, March 7, 2012
Run Barch in SQL Server problem - share drive??
I have a problem with a job moving and zipping file to share drive
What does my Batch?
1) Copy backup device (initially in D:/) into
//SERVER/SHARE/Archived_Backups/
2) Create new folder in //SERVER/SHARE/Archived_Backups/
3) Move the DEVICE into this new folder
4) Zip the DEVICE and named it today.zip
if I run it manually the batch file works perfectly, But if I launch it
with sql server (what I would like to perform) this step does not run
perfectly.
What does this job?
1) run the batch
Step 1
DECLARE @.cmd sysname, @.var sysname
SET @.var = 'start D:\Backups\MyBacth.bat'
EXEC master..xp_cmdshell @.var
2) Overwrite the DEVICE
3) Verify DEVICE integrity
I have already set privileges for sqlservice in to this share
What do i need to do? Any Suggestions?
Thanks in advance
InaSorry,
Thank you for your answer... yes it is running and has network
privileges.
Regards,
Ina
John Bell wrote:
> Hi
> Apart from the typo in your script! You don't say what the SQL Agent account
> is running as and if it has network privileges.
> John
> "ina" wrote:
> > Hello Guys,
> >
> > I have a problem with a job moving and zipping file to share drive
> >
> >
> > What does my Batch?
> >
> >
> >
> > 1) Copy backup device (initially in D:/) into
> > //SERVER/SHARE/Archived_Backups/
> >
> > 2) Create new folder in //SERVER/SHARE/Archived_Backups/
> >
> > 3) Move the DEVICE into this new folder
> >
> > 4) Zip the DEVICE and named it today.zip
> >
> >
> > if I run it manually the batch file works perfectly, But if I launch it
> > with sql server (what I would like to perform) this step does not run
> > perfectly.
> >
> > What does this job?
> >
> > 1) run the batch
> > Step 1
> > DECLARE @.cmd sysname, @.var sysname
> > SET @.var = 'start D:\Backups\MyBacth.bat'
> > EXEC master..xp_cmdshell @.var
> >
> > 2) Overwrite the DEVICE
> >
> > 3) Verify DEVICE integrity
> >
> >
> > I have already set privileges for sqlservice in to this share
> >
> >
> > What do i need to do? Any Suggestions?
> >
> >
> > Thanks in advance
> >
> >
> >
> > Ina
> >
> >|||Hi Ina
Does this mean that you have solved the problem? If not can you log onto the
server as the service account and run the job?
John
"ina" wrote:
> Sorry,
> Thank you for your answer... yes it is running and has network
> privileges.
> Regards,
> Ina
>
> John Bell wrote:
> > Hi
> >
> > Apart from the typo in your script! You don't say what the SQL Agent account
> > is running as and if it has network privileges.
> >
> > John
> >
> > "ina" wrote:
> >
> > > Hello Guys,
> > >
> > > I have a problem with a job moving and zipping file to share drive
> > >
> > >
> > > What does my Batch?
> > >
> > >
> > >
> > > 1) Copy backup device (initially in D:/) into
> > > //SERVER/SHARE/Archived_Backups/
> > >
> > > 2) Create new folder in //SERVER/SHARE/Archived_Backups/
> > >
> > > 3) Move the DEVICE into this new folder
> > >
> > > 4) Zip the DEVICE and named it today.zip
> > >
> > >
> > > if I run it manually the batch file works perfectly, But if I launch it
> > > with sql server (what I would like to perform) this step does not run
> > > perfectly.
> > >
> > > What does this job?
> > >
> > > 1) run the batch
> > > Step 1
> > > DECLARE @.cmd sysname, @.var sysname
> > > SET @.var = 'start D:\Backups\MyBacth.bat'
> > > EXEC master..xp_cmdshell @.var
> > >
> > > 2) Overwrite the DEVICE
> > >
> > > 3) Verify DEVICE integrity
> > >
> > >
> > > I have already set privileges for sqlservice in to this share
> > >
> > >
> > > What do i need to do? Any Suggestions?
> > >
> > >
> > > Thanks in advance
> > >
> > >
> > >
> > > Ina
> > >
> > >
>|||Hello Jonh I was in holidays,
Happy new 2007!!!
I did not solved the problem. my sqlservice has network privileges but
I cannot run this job. So, I did a scheduled task for copy and zip the
backup and run a job to overwrite the existing backup.
I have three disk configurate with my slq server (C --> local, D -->
Data and F --> backup) how can I set up a new one without restall sql
Server again.
Best regards,
Ina
John Bell wrote:
> Hi Ina
> Does this mean that you have solved the problem? If not can you log onto the
> server as the service account and run the job?
> John
> "ina" wrote:
> > Sorry,
> >
> > Thank you for your answer... yes it is running and has network
> > privileges.
> >
> > Regards,
> >
> > Ina
> >
> >
> > John Bell wrote:
> > > Hi
> > >
> > > Apart from the typo in your script! You don't say what the SQL Agent account
> > > is running as and if it has network privileges.
> > >
> > > John
> > >
> > > "ina" wrote:
> > >
> > > > Hello Guys,
> > > >
> > > > I have a problem with a job moving and zipping file to share drive
> > > >
> > > >
> > > > What does my Batch?
> > > >
> > > >
> > > >
> > > > 1) Copy backup device (initially in D:/) into
> > > > //SERVER/SHARE/Archived_Backups/
> > > >
> > > > 2) Create new folder in //SERVER/SHARE/Archived_Backups/
> > > >
> > > > 3) Move the DEVICE into this new folder
> > > >
> > > > 4) Zip the DEVICE and named it today.zip
> > > >
> > > >
> > > > if I run it manually the batch file works perfectly, But if I launch it
> > > > with sql server (what I would like to perform) this step does not run
> > > > perfectly.
> > > >
> > > > What does this job?
> > > >
> > > > 1) run the batch
> > > > Step 1
> > > > DECLARE @.cmd sysname, @.var sysname
> > > > SET @.var = 'start D:\Backups\MyBacth.bat'
> > > > EXEC master..xp_cmdshell @.var
> > > >
> > > > 2) Overwrite the DEVICE
> > > >
> > > > 3) Verify DEVICE integrity
> > > >
> > > >
> > > > I have already set privileges for sqlservice in to this share
> > > >
> > > >
> > > > What do i need to do? Any Suggestions?
> > > >
> > > >
> > > > Thanks in advance
> > > >
> > > >
> > > >
> > > > Ina
> > > >
> > > >
> >
> >|||John Thank you for this tips.
I will try to do that.
Ina
John Bell wrote:
> Hi Ina
> Happy New Year!
> Looking back at your script, can you change the batch file it so that does
> not map the network drive, zips up the backup file before it copies it to the
> UNC? On the extended properties for the step can you then add a log file so
> that any error messages are captured. Then schedule the job to run and post
> the messages from the log file.
> Thanks
> John
>
> "ina" wrote:
> > Hello Jonh I was in holidays,
> >
> > Happy new 2007!!!
> >
> > I did not solved the problem. my sqlservice has network privileges but
> > I cannot run this job. So, I did a scheduled task for copy and zip the
> > backup and run a job to overwrite the existing backup.
> >
> > I have three disk configurate with my slq server (C --> local, D -->
> > Data and F --> backup) how can I set up a new one without restall sql
> > Server again.
> >
> > Best regards,
> >
> > Ina
> >
> > John Bell wrote:
> > > Hi Ina
> > >
> > > Does this mean that you have solved the problem? If not can you log onto the
> > > server as the service account and run the job?
> > >
> > > John
> > >
> > > "ina" wrote:
> > >
> > > > Sorry,
> > > >
> > > > Thank you for your answer... yes it is running and has network
> > > > privileges.
> > > >
> > > > Regards,
> > > >
> > > > Ina
> > > >
> > > >
> > > > John Bell wrote:
> > > > > Hi
> > > > >
> > > > > Apart from the typo in your script! You don't say what the SQL Agent account
> > > > > is running as and if it has network privileges.
> > > > >
> > > > > John
> > > > >
> > > > > "ina" wrote:
> > > > >
> > > > > > Hello Guys,
> > > > > >
> > > > > > I have a problem with a job moving and zipping file to share drive
> > > > > >
> > > > > >
> > > > > > What does my Batch?
> > > > > >
> > > > > >
> > > > > >
> > > > > > 1) Copy backup device (initially in D:/) into
> > > > > > //SERVER/SHARE/Archived_Backups/
> > > > > >
> > > > > > 2) Create new folder in //SERVER/SHARE/Archived_Backups/
> > > > > >
> > > > > > 3) Move the DEVICE into this new folder
> > > > > >
> > > > > > 4) Zip the DEVICE and named it today.zip
> > > > > >
> > > > > >
> > > > > > if I run it manually the batch file works perfectly, But if I launch it
> > > > > > with sql server (what I would like to perform) this step does not run
> > > > > > perfectly.
> > > > > >
> > > > > > What does this job?
> > > > > >
> > > > > > 1) run the batch
> > > > > > Step 1
> > > > > > DECLARE @.cmd sysname, @.var sysname
> > > > > > SET @.var = 'start D:\Backups\MyBacth.bat'
> > > > > > EXEC master..xp_cmdshell @.var
> > > > > >
> > > > > > 2) Overwrite the DEVICE
> > > > > >
> > > > > > 3) Verify DEVICE integrity
> > > > > >
> > > > > >
> > > > > > I have already set privileges for sqlservice in to this share
> > > > > >
> > > > > >
> > > > > > What do i need to do? Any Suggestions?
> > > > > >
> > > > > >
> > > > > > Thanks in advance
> > > > > >
> > > > > >
> > > > > >
> > > > > > Ina
> > > > > >
> > > > > >
> > > >
> > > >
> >
> >