Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Friday, March 30, 2012

Scheduling sqlcmd script in sql agent

Is it possible to schedule a sqlcmd script within sqlagent? That is without running a cmdexec?

Thanks,

what is the actual requirement ... its not clear. you can use XP_cmdshell to execute sqlcmd script from SQL envriornment

Else you can use windows scheduler to execute the sqlcmd script file

Madhu

|||

I was hoping that we could run a sqlcmd script in a normal agent job, similar to the ability to run them in sql management studio window. The advantage of doing that is, the entire solution is in one place.

From your email it sounds as if, there is no way to do this and the only choice is to run a cmdshell agent job or to schedule in the Windows scheduler.

|||

In the Job Step Properties window, in the [General], click on [Type].

There you can select [Operation System ...]

Put your script there.

(

SQLCmd runs SQL commands in the OS environment,

CMDExec runs OS commands in the SQL Server environment -including SQLCmd.exe.

)

However, if you 'should' be able to directly run SQLCmd script as a Job step.

If you posted the command line, we may be able to better advise you about the most efficient method to accomplish your task.

scheduling snapshot and synchronization is missing on the generate scripts

hello all,

i need to bring down the entire replication solution

but just before i do that i need to script. The EM has a generate script feature

but it lacks the schedule for snapshot generation and synchronization

by the way,

whats the fastest way of melting the entire replication solution and

then brinnging them back again.

Can i do replication backup and restore?

regards,

joey

use <published db name>

exec sp_removedbreplication <published db name>

go

use master

sp_dropdistributor 1

go

You can use sp_removedbreplication on the subscriber database as well, and if you have a remote distributor, you can run sp_dropdistributor 1 to remove the distributor.

After that, you can apply your scripts.

sql

Scheduling simple cdosys email task does not work

I currently have a simple cdosys email task that has been scheduled to send a simple email from ssis. The email is sent using an activex script in a "SQL 2000 DTS Package Task". When executed manually, the email is sent ok. When scheduled (and run under our SQL agent account), it fails. Can anyone point me in the right direction? Is this a permissions issue?

'-- this script seems to cause problems, but only when scheduled --
dim mailer
set mailer = CreateObject("CDO.Message")
dim cdoconfig
const cdoDispositionNotificationTo = "urn:schemas:mailheader:disposition-notification-to"
const cdoReturnReceiptTo = "urn:schemas:mailheader:return-receipt-to"
set cdoconfig = CreateObject("CDO.Configuration")

with mailer
set .Configuration = cdoconfig
.BodyPart.charset = "unicode-1-1-utf-8"
.BodyPart.ContentTransferEncoding = "quoted-printable"
.Fields("urn:schemas:httpmail:importance").Value = 2
.Fields.Update

.Subject = "Notification"
.From = "donotreply@.test.com"
.TextBody = "TEST"
.Bcc = "someone@.test.com"
.Send
end with
'-

Also, since I have several DTS packages that are similar, I'd like to keep these packages in the SQL 2000 dts format, instead of converting them into SSIS format and using database mail.

Any help would be appreciated.

Almost certainly permissions. Here's the KB article on this subject:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;918760

Is your SMTP server configured to allow anonymous sending, or to allow the account being used by Agent?

-Doug

|||

Thanks for the article.
We did try method 1 (SQL Agent proxy account). We also set method 2 for serverstorage protection level. We don't have any sensitive information so we skipped method 3 (Encrypt Sensitive with password). As for method 4, we do have package configuration files that have been set as well.

Also, our SMTP server allows anonymous connections.

However, since we are trying to execute activex script tasks using CDOSYS, we're assuming perhaps there is some security permissions issue we overlooked with "component services" perhaps? We also tried adding our SQL agent account (as well as proxy account) into our local admins group, but without any luck. It still runs only manually, but fails for CDOSYS when scheduled.

Scheduling simple cdosys email task does not work

I currently have a simple cdosys email task that has been scheduled to send a simple email from ssis. The email is sent using an activex script in a "SQL 2000 DTS Package Task". When executed manually, the email is sent ok. When scheduled (and run under our SQL agent account), it fails. Can anyone point me in the right direction? Is this a permissions issue?

'-- this script seems to cause problems, but only when scheduled --
dim mailer
set mailer = CreateObject("CDO.Message")
dim cdoconfig
const cdoDispositionNotificationTo = "urn:schemas:mailheader:disposition-notification-to"
const cdoReturnReceiptTo = "urn:schemas:mailheader:return-receipt-to"
set cdoconfig = CreateObject("CDO.Configuration")

with mailer
set .Configuration = cdoconfig
.BodyPart.charset = "unicode-1-1-utf-8"
.BodyPart.ContentTransferEncoding = "quoted-printable"
.Fields("urn:schemas:httpmail:importance").Value = 2
.Fields.Update

.Subject = "Notification"
.From = "donotreply@.test.com"
.TextBody = "TEST"
.Bcc = "someone@.test.com"
.Send
end with
'-

Also, since I have several DTS packages that are similar, I'd like to keep these packages in the SQL 2000 dts format, instead of converting them into SSIS format and using database mail.

Any help would be appreciated.

Almost certainly permissions. Here's the KB article on this subject:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;918760

Is your SMTP server configured to allow anonymous sending, or to allow the account being used by Agent?

-Doug

|||

Thanks for the article.
We did try method 1 (SQL Agent proxy account). We also set method 2 for serverstorage protection level. We don't have any sensitive information so we skipped method 3 (Encrypt Sensitive with password). As for method 4, we do have package configuration files that have been set as well.

Also, our SMTP server allows anonymous connections.

However, since we are trying to execute activex script tasks using CDOSYS, we're assuming perhaps there is some security permissions issue we overlooked with "component services" perhaps? We also tried adding our SQL agent account (as well as proxy account) into our local admins group, but without any luck. It still runs only manually, but fails for CDOSYS when scheduled.

Monday, March 26, 2012

Scheduling DB Scripting

Is there any way I can schedule DB scripting? Let's say I want to script
every production DB on a daily bases.
Thank you in advance for your help
Leon ShargorodskyCreate a job with an ActiveX type and use DMO to script the db's. Here is a
sample:
-- **** SCRIPT ALL USER DB's **** --
Sub Main()
Dim oSS
Set oSS = CreateObject("SQLDMO.SQLServer2")
Dim oDb
Set oDb = CreateObject("SQLDMO.Database2")
Dim lcPwd
Dim lcServer
Dim lcFile
Dim lcDB
lcServer = "BULLDOG2"
oSS.LoginSecure = True
oSS.Connect lcServer
Dim lcDBList
Dim dbArray
lcDBList = "Presents|Northwind|Model"
dbArray = Split(lcDBList, "|")
For Each lcDB In dbArray
Set oDb = oSS.Databases(lcDB)
Dim oT
Set oT = CreateObject("SQLDMO.Transfer2")
lcFile = "C:\Data\DB_Scripts\" & lcDB & "_" & Year(Now) & Right("0"
& Month(Now), 2) & Right("0" & Day(Now), 2) & ".sql"
oT.CopyAllObjects = True
oT.IncludeUsers = True
oT.IncludeLogins = True
oT.IncludeDB = True
oDb.ScriptTransfer oT, 2, lcFile
Set oT = Nothing
Next
Set oDb = Nothing
Set oSS = Nothing
End Sub
Andrew J. Kelly SQL MVP
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in
message news:C0204E43-0613-4D6B-AE28-53F6DCA3B405@.microsoft.com...
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||or you could use a free scripting tool which has a com interface and create
vb script to run it, then create a sql job with an active x step in it and
schedule it to a time you want -
http://www.innovartis.co.uk/database_change_management_evaluation.aspx
It comes free with an evaluation copy of DB Ghost
"Leon Shargorodsky" wrote:
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||Andrew, Mark, thanks a lot for your help!
"mark baekdal" wrote:
> or you could use a free scripting tool which has a com interface and create
> vb script to run it, then create a sql job with an active x step in it and
> schedule it to a time you want -
> http://www.innovartis.co.uk/database_change_management_evaluation.aspx
> It comes free with an evaluation copy of DB Ghost
> "Leon Shargorodsky" wrote:
> > Is there any way I can schedule DB scripting? Let's say I want to script
> > every production DB on a daily bases.
> >
> > Thank you in advance for your help
> >
> > Leon Shargorodsky

Scheduling a script

I wish to run this script daily. Can this be scheduled?

backup log shipmateDB with truncate_only

GHi

Look at SQL Server Agent in BOL. It can schedule jobs and run code.

Regards
----------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@.epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"Myth of Sisyphus)." <teller_117@.hotmail.com> wrote in message
news:iqRFe.4700$q23.748061@.news20.bellglobal.com.. .
>I wish to run this script daily. Can this be scheduled?
>
> backup log shipmateDB with truncate_only
>
> G|||"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:42e7ed30$1_1@.news.bluewin.ch...
> Hi
> Look at SQL Server Agent in BOL. It can schedule jobs and run code.

Can I add though that this script is probably not a good idea.

Either run the database in simple mode or perform actual log backups.

> Regards
> ----------
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "Myth of Sisyphus)." <teller_117@.hotmail.com> wrote in message
> news:iqRFe.4700$q23.748061@.news20.bellglobal.com.. .
> >I wish to run this script daily. Can this be scheduled?
> > backup log shipmateDB with truncate_only
> > G|||Hi Greg,

I do have a log file backup scheduled along with my regular backup.
However, I do get sporatic log file full messages. I then have to run the
script through the query analyzer that appears to solve the problem untill
the next time.

regards

gilbert

"Greg D. Moore (Strider)" <mooregr_deleteth1s@.greenms.com> wrote in message
news:J5VFe.10184$oZ.2845@.newsread2.news.atl.earthl ink.net...
> "Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
> news:42e7ed30$1_1@.news.bluewin.ch...
> > Hi
> > Look at SQL Server Agent in BOL. It can schedule jobs and run code.
> Can I add though that this script is probably not a good idea.
> Either run the database in simple mode or perform actual log backups.
>
> > Regards
> > ----------
> > Mike Epprecht, Microsoft SQL Server MVP
> > Zurich, Switzerland
> > IM: mike@.epprecht.net
> > MVP Program: http://www.microsoft.com/mvp
> > Blog: http://www.msmvps.com/epprecht/
> > "Myth of Sisyphus)." <teller_117@.hotmail.com> wrote in message
> > news:iqRFe.4700$q23.748061@.news20.bellglobal.com.. .
> > >I wish to run this script daily. Can this be scheduled?
> > > > > backup log shipmateDB with truncate_only
> > > > > G
> >|||"Myth of Sisyphus)." <teller_117@.hotmail.com> wrote in message
news:5y4Ge.5644$q23.914966@.news20.bellglobal.com.. .
> Hi Greg,
> I do have a log file backup scheduled along with my regular backup.
> However, I do get sporatic log file full messages. I then have to run the
> script through the query analyzer that appears to solve the problem
untill
> the next time.

But then you've completely invalidated your log backup chain.

I think you need to revisit your disaster recovery scenario since once
you've done the truncate, you can no longer recover anything past the last
transaction back up or full backup.

You're either better of doing transaction log backups more often to avoid
filling up your log, making your log larger, or finding out what's filling
them up.

> regards
> gilbert
>
> "Greg D. Moore (Strider)" <mooregr_deleteth1s@.greenms.com> wrote in
message
> news:J5VFe.10184$oZ.2845@.newsread2.news.atl.earthl ink.net...
> > "Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
> > news:42e7ed30$1_1@.news.bluewin.ch...
> > > Hi
> > > > Look at SQL Server Agent in BOL. It can schedule jobs and run code.
> > > Can I add though that this script is probably not a good idea.
> > Either run the database in simple mode or perform actual log backups.
> > > Regards
> > > ----------
> > > Mike Epprecht, Microsoft SQL Server MVP
> > > Zurich, Switzerland
> > > > IM: mike@.epprecht.net
> > > > MVP Program: http://www.microsoft.com/mvp
> > > > Blog: http://www.msmvps.com/epprecht/
> > > > "Myth of Sisyphus)." <teller_117@.hotmail.com> wrote in message
> > > news:iqRFe.4700$q23.748061@.news20.bellglobal.com.. .
> > > >I wish to run this script daily. Can this be scheduled?
> > > > > > > > backup log shipmateDB with truncate_only
> > > > > > > > G
> > > > > >sql

scheduling a query

I need to scheduling a query to update some records.
I have to use a script in windows task manager or there is another way?
Many ThanksThe SQL Agent is a wonderful wat to schedule a query. Create a job and out
your query in a step.
"Simone" wrote:

> I need to scheduling a query to update some records.
> I have to use a script in windows task manager or there is another way?
> Many Thanks
>
>|||If you are using an edition of SQL Server which has an enterprise
manager and therefor a UI for SQL Server Agent, you can just create a
job with your query. Add a new job, add a new step (Transact SQL
Execution), paste your statement in there and add a schedule for it and
voil=E1, you=B4re done. iof you do=B4n=B4t have a GUI, you can use the
goold old fashioned AT to do your jobs. Just schedule your job by the
Windows Scheduler or AT, suing OSQL to run the query: OSQL -SServername
-UUsername -PPassword -Q"Here is my query".
HTH, jens Suessmeyer.|||you can create a job and schedule that
Jobs are under management-->Sql Server agent-->Jobs
make it a one step job paste your query or proc call in the step
command window and schedule the job
http://sqlservercode.blogspot.com/

scheduling a query

I need to scheduling a query to update some records.
I have to use a script in windows task manager or there is another way?
Many ThanksIf you are using an edition of SQL Server which has an enterprise
manager and therefor a UI for SQL Server Agent, you can just create a
job with your query. Add a new job, add a new step (Transact SQL
Execution), paste your statement in there and add a schedule for it and
voil=E1, you=B4re done. iof you do=B4n=B4t have a GUI, you can use the
goold old fashioned AT to do your jobs. Just schedule your job by the
Windows Scheduler or AT, suing OSQL to run the query: OSQL -SServername
-UUsername -PPassword -Q"Here is my query".
HTH, jens Suessmeyer.|||The SQL Agent is a wonderful wat to schedule a query. Create a job and out
your query in a step.
"Simone" wrote:
> I need to scheduling a query to update some records.
> I have to use a script in windows task manager or there is another way?
> Many Thanks
>
>|||you can create a job and schedule that
Jobs are under management-->Sql Server agent-->Jobs
make it a one step job paste your query or proc call in the step
command window and schedule the job
http://sqlservercode.blogspot.com/

scheduling a query

I need to scheduling a query to update some records.
I have to use a script in windows task manager or there is another way?
Many Thanks
The SQL Agent is a wonderful wat to schedule a query. Create a job and out
your query in a step.
"Simone" wrote:

> I need to scheduling a query to update some records.
> I have to use a script in windows task manager or there is another way?
> Many Thanks
>
>
|||If you are using an edition of SQL Server which has an enterprise
manager and therefor a UI for SQL Server Agent, you can just create a
job with your query. Add a new job, add a new step (Transact SQL
Execution), paste your statement in there and add a schedule for it and
voil=E1, you=B4re done. iof you do=B4n=B4t have a GUI, you can use the
goold old fashioned AT to do your jobs. Just schedule your job by the
Windows Scheduler or AT, suing OSQL to run the query: OSQL -SServername
-UUsername -PPassword -Q"Here is my query".
HTH, jens Suessmeyer.
|||you can create a job and schedule that
Jobs are under management-->Sql Server agent-->Jobs
make it a one step job paste your query or proc call in the step
command window and schedule the job
http://sqlservercode.blogspot.com/

Friday, March 23, 2012

Scheduled Task

Does anyone know how I can run a t-SQL script using the Microsoft Scheduled Task Wizard? I want either Q.A, or E.M to automatically start up and then run a script that I saved on my c: drive.
ThanksSQLAgent service account must have READ access to your C drive. You can have an OS command in the job step that fired OSQL with an -i ponting to the UNC of your C drive (\\your_pc_name\c$ or \\your_pc_name\share_name)|||Try osql and BAT.|||I've never used osql before and am having trouble logging in. It prompts me for the password and the just closes the window. I am putting in my windows password.
Thanks|||-E will let you in without having to enter the password if you have your login on the server.|||I am getting an error that says it doesn't exist or access denied.|||-S your_server_name -E|||Everything worked. Thank you very much for your help.

Wednesday, March 21, 2012

Scheduled report for database names and sizes

Does anyone has a script which gives all databases names and there
allocated, used sizes in SQLserver2k. I want to schedule this to create a
daily report.

Thanks,
Nasir"Nasir" <nmajeed@.prosrm.com> wrote in message
news:40056fa6$0$43848$39cecf19@.news.twtelecom.net. ..
> Does anyone has a script which gives all databases names and there
> allocated, used sizes in SQLserver2k. I want to schedule this to create a
> daily report.
> Thanks,
> Nasir

Depending on what you need, this may be good enough:

exec sp_MSforeachdb 'exec sp_helpdb ?'
and/or
exec sp_MSforeachdb 'exec ?..sp_spaceused'

Note that this will return multiple result sets, which are awkward to
process within SQL Server itself, although it should be straightforward in a
client script. sp_MSforeachdb is not documented, but you can use your own
cursor instead for production.

Simonsql

Friday, March 9, 2012

Scheduled Backup for SQL Server express

Has anyone developed a script (that they're willing to share) that does a
scheduled backup of a SQL Server Express database and that automatically
generates a "dated" backup file - i.e. a new backup file each day as opposed
to a single one that gets overwritten?
Thankshttp://www.sqldbatips.com/showarticle.asp?ID=27
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Sam Malone" <the_sam_malone@.hotmail.com> wrote in message
news:%23keAXwcdGHA.4932@.TK2MSFTNGP03.phx.gbl...
> Has anyone developed a script (that they're willing to share) that does a
scheduled backup of a
> SQL Server Express database and that automatically generates a "dated" bac
kup file - i.e. a new
> backup file each day as opposed to a single one that gets overwritten?
> Thanks
>|||Thanks VERY much, Tibor.
I haven't tried this yet but, at a glance, it seems to be exactly what I
need.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OkGImYddGHA.2456@.TK2MSFTNGP04.phx.gbl...
> http://www.sqldbatips.com/showarticle.asp?ID=27
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Sam Malone" <the_sam_malone@.hotmail.com> wrote in message
> news:%23keAXwcdGHA.4932@.TK2MSFTNGP03.phx.gbl...
>|||Jasper is the one who deserves the credit. :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Sam Malone" <the_sam_malone@.hotmail.com> wrote in message
news:OiUWvThdGHA.536@.TK2MSFTNGP02.phx.gbl...
> Thanks VERY much, Tibor.
> I haven't tried this yet but, at a glance, it seems to be exactly what I n
eed.
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n message
> news:OkGImYddGHA.2456@.TK2MSFTNGP04.phx.gbl...
>

Schedule SQL script

I been trying to figure out how to do this for a while but finally given in and decided to ask here.
I am using SQL express and I think that desnt support automation of SQL scripts (please correct me if I am wrong!)

I want to run a backup script and the plan was to use a bat file and windows task scheduler. But for the life of me I cannot get the bat file to work after trying loads of different example from my searches.

Any help is apreciatedI think you are correct that express doesn't include Agent, which is the scheduling component that comes with the higher SKUs of sql server.

what does the bat file look like? are you using sqlcmd.exe? that's what I would recommend.|||hmm does it have to be called sqlcmd.exe?
I had a file called script.bat and i was writing a one line command to execute the SQL script. I really dont have any idea what im doing I was just following what some forums were saying when I searched :S

thanks|||sqlcmd.exe is a console app you can use to execute sql scripts from the cmd line. the equivalent in 2000 is osql.exe.|||I'm guessing here but I would say that you can pass parameters to sqlcmd.exe can you not? So you could call sqlcmd.exe <parameter1> <parameter2> ... from your batch file and it should run your backup commands for you.

How to connect using SQLcmd (http://msdn2.microsoft.com/en-us/library/ms188247.aspx)
How to execute commands from SQLcmd (http://msdn2.microsoft.com/en-us/library/ms253126(VS.80).aspx)
A break down of SQLcmd options (http://http://www.yukonxml.com/Reference/default.aspx?t=SQLCMD) <-- CHECK THIS ONE OUT.

Bear in mind that your batch script needs to know where the sqlcmd is run from. So it either needs to be in your PATH setting or you need to run your batch script from the same directory (not advisable).|||I really dont have any idea what im doing
You might want to take a step back and make yourself familiar with the SQL Server environment and all the tools that come with it before trying to actually implement something.
Sometimes it's quicker to read the manual first and only then start "coding", instead of trying to cleanup the mess you made because you "don't have any idea what you are doing".

Wednesday, March 7, 2012

Schedule question

Hello all!

I have a small .vbs script that I would like to run as a step in the SQL scheduler. The script is "MsgBox("Database Transfer Succesfull!")"

The client wants to something to let the end user know it was succesful with a pop up message. But it doesn't work, and just hangs up my process. The other steps are SP's and a DTS run.

Any idea's?

TIA!!

Rudy

The SQL Agent is architectured to run on servers, even without any user being logged on when the scheduled task is executed. So it runs the program in separate session, and this message box is "displayed" on the invisible desktop, so nobody can close it, and the process hangs.

Use some other way to get user notified, e.g. send him/her an e-mail, or (if you keep [deprecated] messenger service enabled) run 'net send computer message' command, etc.

Saturday, February 25, 2012

Schedule dabase backup

Hi,
Is it possible to schedule a database backup with SQL 2000?
I would like a script which would be run weekly and the backup file would be
in the format: ..\backupYYYY_MM_DD.rtf
Thanks,
GeorgesYep
You can either use the Maintenance plans or roll your own statement. With
your own statement you would simply add it to a job and apply your schedule
using SQL Server Agent
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"Georges" <gvautherin@.hotmail.com> wrote in message
news:u3yS6bxPDHA.1336@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Is it possible to schedule a database backup with SQL 2000?
> I would like a script which would be run weekly and the backup file would
be
> in the format: ..\backupYYYY_MM_DD.rtf
> Thanks,
> Georges
>|||put the following code in a stored procedure whereby you can dynamically
generate backup filename. Schedule this stored procedure using SQL job.
Ex:
DECLARE @.bkp varchar(500)
SET @.bkp = 'BACKUP DATABASE Pubs TO DISK=''C:\MSSQL7\Backup\' +
CONVERT(varchar(25),GETDATE(), 112) + '.RTF'''
EXEC(@.bkp)
-Vishal
"Georges" <gvautherin@.hotmail.com> wrote in message
news:u3yS6bxPDHA.1336@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Is it possible to schedule a database backup with SQL 2000?
> I would like a script which would be run weekly and the backup file would
be
> in the format: ..\backupYYYY_MM_DD.rtf
> Thanks,
> Georges
>

Tuesday, February 21, 2012

Schedule a T-SQL Script

I have a T-SQL script that creates a SQL Backup using Idera's SQLSafe.
It works great in QA, but I now wish to schedule the backup, and I am
not sure the best approach.
The script contains cleartext accounts and passwords, so I would like
to avoid storing it on a drive.
I thought I could create a stored procedure, but I dont know how I
could then schedule it.
Any thoughts?
TIA,
RobDOH, tried right clicking on the "Jobs" item under Management in EM, I
didnt know I could add jobs on the fly like that!
I just pasted my SQL and scheduled the job.
Simple
:)

schedule

I'm running a job from a schedule which runs a .vbs script
In this script I have the following script to include another file
Function GetFileContents(sFileName)
Dim FSO, ScriptFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ScriptFile = FSO.OpenTextFile(sFilename,1)
GetFileContents = ScriptFile.ReadAll
Set ScriptFile = Nothing
Set FSO = Nothing
End Function
-> ExecuteGlobal GetFileContents("db_conn.vbs")
When I run the job from sql enterprise manager it stops at the row above
If I run the script from the command line, all is good
What's the problem
Thanks
DenisWhat would you expect the current directory to be when running it from
enterprise manager?
"Microsoft" <dzoddi@.mvmnet.com> wrote in message
news:OjDx0yQ8FHA.1032@.TK2MSFTNGP11.phx.gbl...
> I'm running a job from a schedule which runs a .vbs script
> In this script I have the following script to include another file
> Function GetFileContents(sFileName)
> Dim FSO, ScriptFile
> Set FSO = CreateObject("Scripting.FileSystemObject")
> Set ScriptFile = FSO.OpenTextFile(sFilename,1)
> GetFileContents = ScriptFile.ReadAll
> Set ScriptFile = Nothing
> Set FSO = Nothing
> End Function
> -> ExecuteGlobal GetFileContents("db_conn.vbs")
>
> When I run the job from sql enterprise manager it stops at the row above
> If I run the script from the command line, all is good
> What's the problem
> Thanks
> Denis
>