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

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Pass different parameters based on DOW to SP

Author  Topic 

Sqlraider
Yak Posting Veteran

65 Posts

Posted - 2011-05-16 : 14:59:23
I would like to pass different parameters based on the day of the week (DOW) to a Stored Procedure. The T-SQL would be in a SQL Server Agent Job.

Here is what I have but am getting syntax error(s):

Declare @bkpType char(4)
SELECT CASE(DATEPART(dw, CURRENT_TIMESTAMP))
WHEN 1 THEN Set @bkpType = 'Full' -- Sunday
ELSE Set @bkpType = 'Diff'
END

EXEC usp_BackupDB
@bkpType


I want to take Differential backups M-Sat & Full backups on Sunday in one SQL Server Agent Job.

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-16 : 15:23:11
I don't understand why you would have T-SQL do this. Schedule a differential backup in one job, and then have your full backup in another job. It doesn't make sense to do all of this coding when two jobs solves your problem plus is how everyone else handles this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sqlraider
Yak Posting Veteran

65 Posts

Posted - 2011-05-16 : 15:58:39
quote:
Originally posted by tkizer

I don't understand why you would have T-SQL do this. Schedule a differential backup in one job, and then have your full backup in another job. It doesn't make sense to do all of this coding when two jobs solves your problem plus is how everyone else handles this.




Is there a way to schedule a job Daily & not have it run on Sunday? Or do you suggest that on Sunday I run the Full backup after the Differentail? I was trying to avoid running a differential & a full backup on the same DB on the same day (Sunday).
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-16 : 16:00:04
quote:

Is there a way to schedule a job Daily & not have it run on Sunday?


Yes, you select the weekly option in the job schedule and select all days except Sunday.

quote:

Or do you suggest that on Sunday I run the Full backup after the Differentail?


No.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sqlraider
Yak Posting Veteran

65 Posts

Posted - 2011-05-16 : 16:07:00
quote:
Originally posted by tkizer

quote:

Is there a way to schedule a job Daily & not have it run on Sunday?


Yes, you select the weekly option in the job schedule and select all days except Sunday.

quote:

Or do you suggest that on Sunday I run the Full backup after the Differentail?


No.




Doh! I didn't know those options were available when selecting weekly.

Thanks for helping!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-16 : 16:07:39


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -