Click here to Skip to main content
15,113,531 members
Home / Discussions / Database
   

Database

 
GeneralRe: A query with lot of inner queries Pin
Mycroft Holmes30-May-14 13:46
professionalMycroft Holmes30-May-14 13:46 
QuestionProblem with tempdb - MSSQL Pin
Milan K SK28-May-14 5:32
MemberMilan K SK28-May-14 5:32 
AnswerRe: Problem with tempdb - MSSQL Pin
Kornfeld Eliyahu Peter28-May-14 7:39
professionalKornfeld Eliyahu Peter28-May-14 7:39 
QuestionSQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Seuss27-May-14 12:10
MemberSeuss27-May-14 12:10 
AnswerRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Mycroft Holmes27-May-14 13:45
professionalMycroft Holmes27-May-14 13:45 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Seuss27-May-14 21:10
MemberSeuss27-May-14 21:10 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Mycroft Holmes27-May-14 21:22
professionalMycroft Holmes27-May-14 21:22 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Seuss27-May-14 23:14
MemberSeuss27-May-14 23:14 
Does this look efficient and OK?

DECLARE @LastDayOfYear Date, @GetHour INT , @NextNewDate DateTime

SET @LastDayOfYear = DATEADD(yy, DATEDIFF(yy,0,GETDATE()) + 1, -1)

SET @GetHour = datepart(hour, GETDATE()) -- returns hour

--Get Today date to compare to the last day of December in current year
IF (FORMAT(GETDATE(), 'yyyy-MM-dd') = FORMAT(@LastDayOfYear, 'yyyy-MM-dd')) AND @GetHour >= 20
BEGIN
--If Equal - then increase the next 2 years
SET @NextNewDate = FORMAT(DATEADD(YEAR, 2, @LastDayOfYear), 'yyyy-MM-dd HH:mm:ss')
END
ELSE
SET @NextNewDate = FORMAT(@LastDayOfYear, 'yyyy-MM-dd HH:mm:ss')

PRINT @NextNewDate


WHILE (CONVERT(DATE,@currDate, 101) <= @NextNewDate)
BEGIN


Second Issue - "so run the job every month, if it does not meet your criteria then let it wait for next month."

How do you make it meet your criteria i.e. if it falls on 31st December of each year?

modified 28-May-14 4:49am.

GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
NitinDhapte16-Jun-14 2:55
MemberNitinDhapte16-Jun-14 2:55 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Seuss27-May-14 23:28
MemberSeuss27-May-14 23:28 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Mycroft Holmes27-May-14 23:55
professionalMycroft Holmes27-May-14 23:55 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Seuss28-May-14 0:00
MemberSeuss28-May-14 0:00 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Seuss28-May-14 6:28
MemberSeuss28-May-14 6:28 
AnswerRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Chris Quinn27-May-14 23:53
MemberChris Quinn27-May-14 23:53 
GeneralRe: SQL Server 2012 Agent Job & stored procedure issue URGENT Pin
Seuss28-May-14 0:01
MemberSeuss28-May-14 0:01 
QuestionHow to select the records who are completed exactly years comparing with joining date and todays date Pin
ven75326-May-14 7:09
Memberven75326-May-14 7:09 
AnswerRe: How to select the records who are completed exactly years comparing with joining date and todays date Pin
jschell26-May-14 9:11
Memberjschell26-May-14 9:11 
GeneralRe: How to select the records who are completed exactly years comparing with joining date and todays date Pin
ven75326-May-14 22:27
Memberven75326-May-14 22:27 
AnswerRe: How to select the records who are completed exactly years comparing with joining date and todays date Pin
Mycroft Holmes26-May-14 13:52
professionalMycroft Holmes26-May-14 13:52 
GeneralRe: How to select the records who are completed exactly years comparing with joining date and todays date Pin
Sunasara Imdadhusen26-May-14 22:30
professionalSunasara Imdadhusen26-May-14 22:30 
AnswerRe: How to select the records who are completed exactly years comparing with joining date and todays date Pin
NitinDhapte16-Jun-14 3:18
MemberNitinDhapte16-Jun-14 3:18 
Questionaccess2010 pivot table Pin
hakata21-May-14 6:59
Memberhakata21-May-14 6:59 
QuestionAbnormal Behavior of SQL Server 2008 Enterprise Store Procedure Pin
jugnu_ad20-May-14 21:52
Memberjugnu_ad20-May-14 21:52 
AnswerRe: Abnormal Behavior of SQL Server 2008 Enterprise Store Procedure Pin
Richard MacCutchan20-May-14 22:45
mveRichard MacCutchan20-May-14 22:45 
GeneralRe: Abnormal Behavior of SQL Server 2008 Enterprise Store Procedure Pin
jugnu_ad20-May-14 22:47
Memberjugnu_ad20-May-14 22:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.