Showing posts with label users. Show all posts
Showing posts with label users. Show all posts

Friday, March 30, 2012

Scheduling SQL Server 2005 report server

I'm looking a way to schedule a report to be generated in pre-define time and push it out to my users through email or file share any format (excell, Word, etc). Any help would be greatly appreciated.

When you view the report in a browser you'll see four tabs - View, Properties, History, Subscriptions. Create a new subscription and then enter the recipient (actual email address required) and select the Render Format as Excel, PDF, Web Archive etc. You can also set the date, time and frequency of the subscription.

Hope this helps,

Aidan

Friday, March 23, 2012

Scheduler Mystery

I have a scheduled job that executes sql to dump tran with no log. I have i
t
running at night so no users are affected. The next morning the job says it
succeded with no errors accounted for. However I have checked the size of
the ldf and it is huge. Our server space is getting smaller and smaller
every day, so I am suspect that the log file is not being truncated. When I
checked the SQL server event viewer, it shows an Error application event whe
n
the truncate process is started. Can anyone tell me why the scheduled job
shows a successfull run, while the event viewer tells another story?What version of SQL Server?

>I have a scheduled job that executes sql to dump tran with no log.
As of 7.0, we use BACKUP instead of DUMP, but DUMP is still allowed. Anyhow,
this doesn't shrink
physical file size. Are you doing regular transaction log backups? If nor, u
se simple recovery
model. If you are, don't just cut the log as it will break the log backup se
quence.
As for shrinking the file size, I've listed a number of articles in this art
icle:
http://www.karaszi.com/SQLServer/info_dont_shrink.asp
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Toco" <Toco@.discussions.microsoft.com> wrote in message
news:723A119C-5D64-4C36-9865-9BD8FBAF2775@.microsoft.com...
>I have a scheduled job that executes sql to dump tran with no log. I have
it
> running at night so no users are affected. The next morning the job says
it
> succeded with no errors accounted for. However I have checked the size of
> the ldf and it is huge. Our server space is getting smaller and smaller
> every day, so I am suspect that the log file is not being truncated. When
I
> checked the SQL server event viewer, it shows an Error application event w
hen
> the truncate process is started. Can anyone tell me why the scheduled job
> shows a successfull run, while the event viewer tells another story?

Friday, March 9, 2012

schedule structure

Hi,
I need to set up the schedule for email remainder for my users. It will be very similiar to the schedule in MS SQL server. I would like to see the data structure of sql schedules. where can I see it? any suggestions on how to do it? ThanksYou will find these in msdb. Have a look at sysjobs,sysjobsteps and
sysjobschedules
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Jen" <anonymous@.discussions.microsoft.com> wrote in message
news:20D70C27-D893-4CA7-AD46-9E95D8BD3E2F@.microsoft.com...
> Hi,
> I need to set up the schedule for email remainder for my users. It will be
very similiar to the schedule in MS SQL server. I would like to see the data
structure of sql schedules. where can I see it? any suggestions on how to do
it? Thanks|||Thanks. in sysjobschedules table, the column freq_type, freq_interval, freq_subday_type, freq_subday_interval, freq_relatice_interval, freq_recurrence_factor all have numbers, what are these numbers referred? I mean if I can know what the data means I can understand better about the column like freq_subday_type. Thank
-- Jasper Smith wrote: --
You will find these in msdb. Have a look at sysjobs,sysjobsteps an
sysjobschedule
--
HT
Jasper Smith (SQL Server MVP
I support PASS - the definitive, globa
community for SQL Server professionals
http://www.sqlpass.or
"Jen" <anonymous@.discussions.microsoft.com> wrote in messag
news:20D70C27-D893-4CA7-AD46-9E95D8BD3E2F@.microsoft.com..
> Hi
>> I need to set up the schedule for email remainder for my users. It will b
very similiar to the schedule in MS SQL server. I would like to see the dat
structure of sql schedules. where can I see it? any suggestions on how to d
it? Thank

schedule structure

Hi,
I need to set up the schedule for email remainder for my users. It will be v
ery similiar to the schedule in MS SQL server. I would like to see the data
structure of sql schedules. where can I see it? any suggestions on how to do
it? ThanksYou will find these in msdb. Have a look at sysjobs,sysjobsteps and
sysjobschedules
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Jen" <anonymous@.discussions.microsoft.com> wrote in message
news:20D70C27-D893-4CA7-AD46-9E95D8BD3E2F@.microsoft.com...
> Hi,
> I need to set up the schedule for email remainder for my users. It will be
very similiar to the schedule in MS SQL server. I would like to see the data
structure of sql schedules. where can I see it? any suggestions on how to do
it? Thanks|||Thanks. in sysjobschedules table, the column freq_type, freq_interval, freq_
subday_type, freq_subday_interval, freq_relatice_interval, freq_recurrence_f
actor all have numbers, what are these numbers referred? I mean if I can kno
w what the data means I can
understand better about the column like freq_subday_type. Thanks
-- Jasper Smith wrote: --
You will find these in msdb. Have a look at sysjobs,sysjobsteps and
sysjobschedules
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Jen" <anonymous@.discussions.microsoft.com> wrote in message
news:20D70C27-D893-4CA7-AD46-9E95D8BD3E2F@.microsoft.com...
> Hi,
very similiar to the schedule in MS SQL server. I would like to see the data
structure of sql schedules. where can I see it? any suggestions on how to do
it? Thanks

Wednesday, March 7, 2012

Schedule once per hour

Is there a way to schedule a subscription once per hour from 8am to 5pm.
I have a report that users want emailed every hour or every other hour. I
can only figure out how to do this for a whold day.
For instance, in windows task scheduler it gives you an option to run every
'X' hours between Xam and Xpm.
Thanks.I have had this reuest too. Could not find a solution.
You could send the reports to a file share and let the user pick them up
manually. A utility program could probably delete all files there the
creation hour is < 8 or > 17.

Saturday, February 25, 2012

schedule email function

Hi all,
I am looking for scripts or method could use sql sever periodaically send
out emails to alert users according to the particular time log setting.
Thx in advance,
Fox NewbiewHi Fox,
What do you want to send ? Which version are you using ? (I am asking,
becasue there had been some changes within the SQL Mail in 2k5)
Are you able to install a MAPI profile on your server ? Is the server
running under the local system accoutn or a domain account ?
You see, you need to provide some more information first ;-)
HTH, Jens Suessmeyer.|||I would like to send out html format email to users to alert them in
periodically. I am using W2k sp4 and is running as domaint account.
I would go for with or without MAPI solution are both welcome.
Thx so much
"Jens" wrote:
> Hi Fox,
>
> What do you want to send ? Which version are you using ? (I am asking,
> becasue there had been some changes within the SQL Mail in 2k5)
> Are you able to install a MAPI profile on your server ? Is the server
> running under the local system accoutn or a domain account ?
> You see, you need to provide some more information first ;-)
> HTH, Jens Suessmeyer.
>|||I'd download and use xp_smtp_sendmail from www.sqldev.net.
In 2005, SMTP support and HTML are built-in to the new "Database Mail" functionality.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
news:F09A5612-B171-4402-A213-08C91A4D1C8B@.microsoft.com...
>I would like to send out html format email to users to alert them in
> periodically. I am using W2k sp4 and is running as domaint account.
> I would go for with or without MAPI solution are both welcome.
> Thx so much
> "Jens" wrote:
>> Hi Fox,
>>
>> What do you want to send ? Which version are you using ? (I am asking,
>> becasue there had been some changes within the SQL Mail in 2k5)
>> Are you able to install a MAPI profile on your server ? Is the server
>> running under the local system accoutn or a domain account ?
>> You see, you need to provide some more information first ;-)
>> HTH, Jens Suessmeyer.
>>|||Does it possible not using SQL mail ? Since I have an retriction on not allow
install outlook, once outlook missing SQL mail is not workable.
"Tibor Karaszi" wrote:
> I'd download and use xp_smtp_sendmail from www.sqldev.net.
> In 2005, SMTP support and HTML are built-in to the new "Database Mail" functionality.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
> news:F09A5612-B171-4402-A213-08C91A4D1C8B@.microsoft.com...
> >I would like to send out html format email to users to alert them in
> > periodically. I am using W2k sp4 and is running as domaint account.
> >
> > I would go for with or without MAPI solution are both welcome.
> >
> > Thx so much
> >
> > "Jens" wrote:
> >
> >> Hi Fox,
> >>
> >>
> >> What do you want to send ? Which version are you using ? (I am asking,
> >> becasue there had been some changes within the SQL Mail in 2k5)
> >>
> >> Are you able to install a MAPI profile on your server ? Is the server
> >> running under the local system accoutn or a domain account ?
> >>
> >> You see, you need to provide some more information first ;-)
> >>
> >> HTH, Jens Suessmeyer.
> >>
> >>
>
>|||Hi Fox,
Your are right. It is a SMTP based extended procedure to send emails.
The only restriction which perhaps might keep you away from using it,
is that i can=B4t autenticate at a SMTP server, so the smtp server has
to accept only non authenticated users. But as a workaround you can
also specify a virtual SMPT Server (which is part of every Windows 2k >
version), which relay the mails to the secure server WITH
authentication.
HTH, jens Suessmeyer.|||None of the two I mentioned uses MAPI, i.e., they do not require Outlook.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
news:B52620EA-0055-4B0D-94E0-A597C2B19367@.microsoft.com...
> Does it possible not using SQL mail ? Since I have an retriction on not allow
> install outlook, once outlook missing SQL mail is not workable.
> "Tibor Karaszi" wrote:
>> I'd download and use xp_smtp_sendmail from www.sqldev.net.
>> In 2005, SMTP support and HTML are built-in to the new "Database Mail" functionality.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
>> news:F09A5612-B171-4402-A213-08C91A4D1C8B@.microsoft.com...
>> >I would like to send out html format email to users to alert them in
>> > periodically. I am using W2k sp4 and is running as domaint account.
>> >
>> > I would go for with or without MAPI solution are both welcome.
>> >
>> > Thx so much
>> >
>> > "Jens" wrote:
>> >
>> >> Hi Fox,
>> >>
>> >>
>> >> What do you want to send ? Which version are you using ? (I am asking,
>> >> becasue there had been some changes within the SQL Mail in 2k5)
>> >>
>> >> Are you able to install a MAPI profile on your server ? Is the server
>> >> running under the local system accoutn or a domain account ?
>> >>
>> >> You see, you need to provide some more information first ;-)
>> >>
>> >> HTH, Jens Suessmeyer.
>> >>
>> >>
>>|||Tibor,
Correct me if i got wrong, since I get down to www.sqldev.net and only find
xp_smtp_sendmail use xp_sendmail as well and xp_send mail from SQL mail and I
need to install outlook on production server and as admin acccount to send
out mails, which I am not allowing to install any outlook kind of programs on
production server.
Any alter suggestions on schdule a job to send out mail at periodically ?
Thx in advance !
Best Regards,
Fox
"Tibor Karaszi" wrote:
> None of the two I mentioned uses MAPI, i.e., they do not require Outlook.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
> news:B52620EA-0055-4B0D-94E0-A597C2B19367@.microsoft.com...
> > Does it possible not using SQL mail ? Since I have an retriction on not allow
> > install outlook, once outlook missing SQL mail is not workable.
> >
> > "Tibor Karaszi" wrote:
> >
> >> I'd download and use xp_smtp_sendmail from www.sqldev.net.
> >>
> >> In 2005, SMTP support and HTML are built-in to the new "Database Mail" functionality.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
> >> news:F09A5612-B171-4402-A213-08C91A4D1C8B@.microsoft.com...
> >> >I would like to send out html format email to users to alert them in
> >> > periodically. I am using W2k sp4 and is running as domaint account.
> >> >
> >> > I would go for with or without MAPI solution are both welcome.
> >> >
> >> > Thx so much
> >> >
> >> > "Jens" wrote:
> >> >
> >> >> Hi Fox,
> >> >>
> >> >>
> >> >> What do you want to send ? Which version are you using ? (I am asking,
> >> >> becasue there had been some changes within the SQL Mail in 2k5)
> >> >>
> >> >> Are you able to install a MAPI profile on your server ? Is the server
> >> >> running under the local system accoutn or a domain account ?
> >> >>
> >> >> You see, you need to provide some more information first ;-)
> >> >>
> >> >> HTH, Jens Suessmeyer.
> >> >>
> >> >>
> >>
> >>
> >>
>|||xp_smtp_sendmail does *not* use xp_sendmail. Where did you read that?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
news:4FE4D1D2-EA6F-47A3-B8E4-178003E7BCEA@.microsoft.com...
> Tibor,
> Correct me if i got wrong, since I get down to www.sqldev.net and only find
> xp_smtp_sendmail use xp_sendmail as well and xp_send mail from SQL mail and I
> need to install outlook on production server and as admin acccount to send
> out mails, which I am not allowing to install any outlook kind of programs on
> production server.
> Any alter suggestions on schdule a job to send out mail at periodically ?
> Thx in advance !
> Best Regards,
> Fox
> "Tibor Karaszi" wrote:
>> None of the two I mentioned uses MAPI, i.e., they do not require Outlook.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>> Blog: http://solidqualitylearning.com/blogs/tibor/
>>
>> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
>> news:B52620EA-0055-4B0D-94E0-A597C2B19367@.microsoft.com...
>> > Does it possible not using SQL mail ? Since I have an retriction on not allow
>> > install outlook, once outlook missing SQL mail is not workable.
>> >
>> > "Tibor Karaszi" wrote:
>> >
>> >> I'd download and use xp_smtp_sendmail from www.sqldev.net.
>> >>
>> >> In 2005, SMTP support and HTML are built-in to the new "Database Mail" functionality.
>> >>
>> >> --
>> >> Tibor Karaszi, SQL Server MVP
>> >> http://www.karaszi.com/sqlserver/default.asp
>> >> http://www.solidqualitylearning.com/
>> >>
>> >>
>> >> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
>> >> news:F09A5612-B171-4402-A213-08C91A4D1C8B@.microsoft.com...
>> >> >I would like to send out html format email to users to alert them in
>> >> > periodically. I am using W2k sp4 and is running as domaint account.
>> >> >
>> >> > I would go for with or without MAPI solution are both welcome.
>> >> >
>> >> > Thx so much
>> >> >
>> >> > "Jens" wrote:
>> >> >
>> >> >> Hi Fox,
>> >> >>
>> >> >>
>> >> >> What do you want to send ? Which version are you using ? (I am asking,
>> >> >> becasue there had been some changes within the SQL Mail in 2k5)
>> >> >>
>> >> >> Are you able to install a MAPI profile on your server ? Is the server
>> >> >> running under the local system accoutn or a domain account ?
>> >> >>
>> >> >> You see, you need to provide some more information first ;-)
>> >> >>
>> >> >> HTH, Jens Suessmeyer.
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>|||You are right ! Thx
"Tibor Karaszi" wrote:
> xp_smtp_sendmail does *not* use xp_sendmail. Where did you read that?
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
> news:4FE4D1D2-EA6F-47A3-B8E4-178003E7BCEA@.microsoft.com...
> > Tibor,
> >
> > Correct me if i got wrong, since I get down to www.sqldev.net and only find
> > xp_smtp_sendmail use xp_sendmail as well and xp_send mail from SQL mail and I
> > need to install outlook on production server and as admin acccount to send
> > out mails, which I am not allowing to install any outlook kind of programs on
> > production server.
> >
> > Any alter suggestions on schdule a job to send out mail at periodically ?
> >
> > Thx in advance !
> >
> > Best Regards,
> > Fox
> >
> > "Tibor Karaszi" wrote:
> >
> >> None of the two I mentioned uses MAPI, i.e., they do not require Outlook.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >> Blog: http://solidqualitylearning.com/blogs/tibor/
> >>
> >>
> >> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
> >> news:B52620EA-0055-4B0D-94E0-A597C2B19367@.microsoft.com...
> >> > Does it possible not using SQL mail ? Since I have an retriction on not allow
> >> > install outlook, once outlook missing SQL mail is not workable.
> >> >
> >> > "Tibor Karaszi" wrote:
> >> >
> >> >> I'd download and use xp_smtp_sendmail from www.sqldev.net.
> >> >>
> >> >> In 2005, SMTP support and HTML are built-in to the new "Database Mail" functionality.
> >> >>
> >> >> --
> >> >> Tibor Karaszi, SQL Server MVP
> >> >> http://www.karaszi.com/sqlserver/default.asp
> >> >> http://www.solidqualitylearning.com/
> >> >>
> >> >>
> >> >> "Fox newbiew" <Foxnewbiew@.discussions.microsoft.com> wrote in message
> >> >> news:F09A5612-B171-4402-A213-08C91A4D1C8B@.microsoft.com...
> >> >> >I would like to send out html format email to users to alert them in
> >> >> > periodically. I am using W2k sp4 and is running as domaint account.
> >> >> >
> >> >> > I would go for with or without MAPI solution are both welcome.
> >> >> >
> >> >> > Thx so much
> >> >> >
> >> >> > "Jens" wrote:
> >> >> >
> >> >> >> Hi Fox,
> >> >> >>
> >> >> >>
> >> >> >> What do you want to send ? Which version are you using ? (I am asking,
> >> >> >> becasue there had been some changes within the SQL Mail in 2k5)
> >> >> >>
> >> >> >> Are you able to install a MAPI profile on your server ? Is the server
> >> >> >> running under the local system accoutn or a domain account ?
> >> >> >>
> >> >> >> You see, you need to provide some more information first ;-)
> >> >> >>
> >> >> >> HTH, Jens Suessmeyer.
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
>

Tuesday, February 21, 2012

Schedule a scripted restore on 2005 Express from .bak file.

Hi i have an web app demo that allows users to add info and change attributes within a SQL 2005 Express DB. I'd like to restore a clean copy of this database every couple of hours from a .bak file using a Windows scheduled task on the server. Has anyone got a .sql script for database restoration that i could use and call using a .cmd script file? Thanks.

Hi TheGrox,

Generally speaking the sql restoration script is like this:

RESTORE DATABASE [Your_databasename] FROM DISK = N'File_Path\BCKUP.bak' WITH FILE = 1, NOUNLOAD, STATS = 10
GO

However, I don't think it can be used from a .cmd script file. To run .sql script file, you need to run it within sql server query analyzer (if you run it from a .cmd script, first it will jump up a window asking your to login to sql server, even though you enter the server name and user/password and login successfully, that sql script file will be opened there while won't be executed until you click the execute button from the GUI).

I think there are two solutions for you requirment. One solution is the easist, upgrade your sql express to a full vertion and use Server Agent-> Jobs. Run that script in a job and schedule the job to run at a sepcific time frequency. I believe it won't cost you more than 5 minutes;

The second solution is to use ado.net.Open your visual studio and create a new project, build a connection to your database first and then send the restore sqlcommand to it. Compile and build you project and after that, you create a windows schedule task and run that application regularly.

Hope my suggestion helps

|||

Hi, thanks for the suggestions. The running the .sql from a .cmd file isnt a problem, i already do that to automatically back up all DB's in my SQL Express instance by having a file called BackupDB.cmd with the following code:

CLS
ECHO OFF
ECHO Testing to make sure directories exist.
IF NOT EXIST C:\SQLBackups MD C:\SQLBackups

ECHO Complete with directory creation
ECHO **********************************************************
ECHO Backing up databases......
sqlcmd -S .\SQLEXPRESS -i c:\Windows\BackupExpress.sql -o C:\SQLbackups\backup.log
ECHO **********************************************************
ECHO Backup complete. Look in the C:\SQLBackups\Backup.log file for information.

ECHO ON

The BackupExpress.sql file is simply a script that loops through all databases on the server and creates a .bak file for each of them in the specified directory. Works nicely andmeans i dont need to reconfigure anything if a new DB is created, it is just automatically included in the backups.

So i guess i just need to create a Restore.sql script using the syntax you quoted and call it as above. The command runs under the context of a valid SQL user account specified when the scheduled task is created so login is not an issue.

The script for the BackupExpress.sql file if anyone is interested in using it is:

/**File Name: BackupExpress.sqlDescription: Backs up all databases. This script is mainly meant for SQL Express instancesThe script requires a C:\SQLBackups directory by default to backup to but can be changed with the @.OutputPath variable.Accompanying file is BackupExpress.cmd, which is used to schedule the script.**/SET QUOTED_IDENTIFIEROFF USE masterGOSET NOCOUNT ON DECLARE @.dayofweekvarchar(20)SELECT @.dayofweek =CASE datepart(dw,getdate())WHEN 1THEN'Sunday'WHEN 2THEN'Monday'WHEN 3THEN'Tuesday'WHEN 4THEN'Wednesday'WHEN 5THEN'Thursday'WHEN 6THEN'Friday'WHEN 7THEN'Saturday'ENDDECLARE @.OutputPathvarchar(500)DECLARE @.DatabaseBackupFilevarchar(500)DECLARE @.FolderNamevarchar(25)DECLARE @.DatabaseNamevarchar(25)DECLARE @.strSQLvarchar(2000)DECLARE @.hostnamevarchar(255)SET @.hostname = (select replace(convert(varchar(255),serverproperty('SERVERNAME')),'\','_'))SET @.OutputPath ='C:\SQLBackups'DECLARE cur_BackupCURSOR FOR select name fromsysdatabaseswhere name !='tempdb'OPEN cur_Backup-- Fetch the db names from CursorFETCH NEXT FROM cur_BackupINTO @.DatabaseNameWHILE@.@.FETCH_STATUS = 0BEGINSET @.DatabaseBackupFile = @.OutputPath +'\' + @.hostname +'-' + @.DatabaseName +'-' + @.dayofweek +'.bak'print @.DatabaseBackupFileSET @.strSQL ='BACKUP DATABASE '+@.DatabaseName+' TO DISK = "'+ @.DatabaseBackupFile+'" WITH RETAINDAYS = 1, NOFORMAT, INIT, NAME = N''Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 10'PRINT @.strSQLEXEC (@.strSQL)FETCH NEXT FROM cur_BackupINTO @.DatabaseNameEND-- Distroy CursorCLOSE cur_BackupDEALLOCATE cur_BackupSET NOCOUNT OFF