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.
Author |
Topic |
edyl
Starting Member
35 Posts |
Posted - 2012-11-13 : 18:12:10
|
Hello Everyone,In my stored procedure I want a block to do nothing if its Sunday or Monday but do its regular "inserts and updates" for rest of the days in the week. I have done some thing that gets the work done, but it doesn't seem to be a clean way to do it. Is there a better way to do it. Here is what I did,Create procedure MyStoredProcASBEGIN... ... ...... ... ...declare @today varchar(10)set @today = DATENAME(DW,GETDATE());IF @today = 'Sunday' OR @today = 'Monday' BEGIN PRINT 'No Update Required' END;ELSE BEGIN ... ... ... "My Regular Inserts and Updates" ... ... ... END I am avoiding the regular updates and inserts on Sundays and Mondays by simply allowing my script to go to somewhere else not absolutely required for it to go to - here printing the message 'No Update Required'. I would rather not print this message if I can. Is there a better/cleaner way to handle this type of situation? Any suggestions and recommendations highly appreciated.Thanks. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-11-13 : 18:17:50
|
[code]CREATE PROCEDURE MyStoredProcASIF DATENAME(DW,GETDATE()) IN('Sunday','Monday') RETURN; ... ... ... "My Regular Inserts AND Updates" ... ... ... [/code] |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-14 : 07:17:09
|
quote: Originally posted by visakh16 i prefer logic likeIF DATEDIFF(dd,0,GETDATE())%7 > 4 RETURN...as its independent of language and regional settingshttp://visakhm.blogspot.in/2012/08/creating-server-independent-day.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Well,well!! It's about time!!! You do know that SQL Team just isn't the same without you around, don't you?!?Welcome back! |
 |
|
edyl
Starting Member
35 Posts |
Posted - 2012-11-14 : 11:13:56
|
Thank you much. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-11-15 : 05:42:47
|
quote: Originally posted by sunitabeck
quote: Originally posted by visakh16 i prefer logic likeIF DATEDIFF(dd,0,GETDATE())%7 > 4 RETURN...as its independent of language and regional settingshttp://visakhm.blogspot.in/2012/08/creating-server-independent-day.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Well,well!! It's about time!!! You do know that SQL Team just isn't the same without you around, don't you?!?Welcome back!
Thank you Just dropped in for checking mails...I'm still in vacation with the newest member of my family ...our lil Angel ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|