Click here to Skip to main content
15,887,434 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Server null date 01/01/1900 possible issue - a question Pin
Eddy Vluggen1-May-13 6:37
professionalEddy Vluggen1-May-13 6:37 
AnswerRe: SQL Server null date 01/01/1900 possible issue - a question Pin
jschell1-May-13 8:28
jschell1-May-13 8:28 
GeneralRe: SQL Server null date 01/01/1900 possible issue - a question Pin
Richard Deeming1-May-13 8:43
mveRichard Deeming1-May-13 8:43 
GeneralRe: SQL Server null date 01/01/1900 possible issue - a question Pin
GuyThiebaut1-May-13 9:19
professionalGuyThiebaut1-May-13 9:19 
GeneralRe: SQL Server null date 01/01/1900 possible issue - a question Pin
jschell2-May-13 7:59
jschell2-May-13 7:59 
Questionhow to union some table in a while loop to a table Pin
mhd.sbt1-May-13 3:49
mhd.sbt1-May-13 3:49 
AnswerRe: how to union some table in a while loop to a table Pin
Richard Deeming1-May-13 3:57
mveRichard Deeming1-May-13 3:57 
GeneralRe: how to union some table in a while loop to a table Pin
mhd.sbt1-May-13 4:10
mhd.sbt1-May-13 4:10 
hello
thanks for reply
my main code is:
SQL
ALTER PROCEDURE [dbo].[lfd__GetFullPersonnelDetails]
(
@PersonnelList nvarchar(MAX),
@WorkPeriodID int,
@WorkPeriodYear int
)  AS
Declare @startDate SMALLDATETIME
Declare @endDate SMALLDATETIME
Declare @PersonnelBaseID INT

WHILE(LEN(@PersonnelList) > 0)
BEGIN
	SET @PersonnelBaseID = SUBSTRING(@PersonnelList, 0, PATINDEX('%,%',@PersonnelList))
	IF(@PersonnelBaseID != 0)
		SET @PersonnelList = SUBSTRING(@PersonnelList, LEN(CAST (@PersonnelBaseID AS NVARCHAR) + ',') + 1, LEN(@PersonnelList))
	ELSE
		BEGIN
			SET @PersonnelBaseID=CAST(@PersonnelList AS INT)
			SET @PersonnelList = SUBSTRING(@PersonnelList, LEN(@PersonnelList + ',') + 1, LEN(@PersonnelList))
		END
	
	 set @startDate=(select top 1 [date] as startdate 
		from 
			lfd_DailyStatistics
		 where 
			PersonnelBaseID = @PersonnelBaseID and [Year] = @WorkPeriodYear and  WorkingPeriodID = @WorkPeriodID 
		order by date asc)

	 set @endDate=(select top 1 [date] as startdate 
		from 
			lfd_DailyStatistics
		 where 
			PersonnelBaseID = @PersonnelBaseID and [Year] = @WorkPeriodYear and  WorkingPeriodID = @WorkPeriodID 
		order by date desc)

	SELECT 
		dailyAbsences.*,
		CAST(CASE WHEN calculationQueue.[StartDate] IS NULL THEN 0 ELSE 1 END AS bit) AS [NeedsRecalculation] 
	FROM 
		lfd_dailyAbsence dailyAbsences LEFT JOIN
		lfd_CalculationQueue calculationQueue ON dailyAbsences.[PersonnelBaseID] = calculationQueue.[PersonnelBaseID] AND calculationQueue.[StartDate] <= @endDate 
	WHERE 
		dailyAbsences.[PersonnelBaseID] = @PersonnelBaseID AND
		dailyAbsences.[StartDate] >= @startDate AND 
		dailyAbsences.[EndDate] <= DATEADD(day, 1, @endDate)
	ORDER BY
		dailyAbsences.[StartDate]
	
END

start date and end date change in each repeat
GeneralRe: how to union some table in a while loop to a table Pin
GuyThiebaut1-May-13 4:31
professionalGuyThiebaut1-May-13 4:31 
GeneralRe: how to union some table in a while loop to a table Pin
Richard Deeming1-May-13 4:33
mveRichard Deeming1-May-13 4:33 
GeneralRe: how to union some table in a while loop to a table Pin
mhd.sbt1-May-13 5:04
mhd.sbt1-May-13 5:04 
AnswerRe: how to union some table in a while loop to a table Pin
Corporal Agarn1-May-13 4:20
professionalCorporal Agarn1-May-13 4:20 
GeneralRe: how to union some table in a while loop to a table Pin
mhd.sbt1-May-13 4:26
mhd.sbt1-May-13 4:26 
GeneralRe: how to union some table in a while loop to a table Pin
Eddy Vluggen1-May-13 4:59
professionalEddy Vluggen1-May-13 4:59 
QuestionSSE 2008 R2 Backup Strategy Pin
Richard.Berry10030-Apr-13 19:47
Richard.Berry10030-Apr-13 19:47 
AnswerRe: SSE 2008 R2 Backup Strategy Pin
GuyThiebaut30-Apr-13 21:56
professionalGuyThiebaut30-Apr-13 21:56 
GeneralRe: SSE 2008 R2 Backup Strategy Pin
Richard.Berry10030-Apr-13 22:16
Richard.Berry10030-Apr-13 22:16 
GeneralRe: SSE 2008 R2 Backup Strategy Pin
GuyThiebaut30-Apr-13 22:43
professionalGuyThiebaut30-Apr-13 22:43 
GeneralRe: SSE 2008 R2 Backup Strategy Pin
Richard.Berry10030-Apr-13 23:18
Richard.Berry10030-Apr-13 23:18 
GeneralRe: SSE 2008 R2 Backup Strategy Pin
GuyThiebaut30-Apr-13 23:34
professionalGuyThiebaut30-Apr-13 23:34 
GeneralRe: SSE 2008 R2 Backup Strategy Pin
Richard.Berry1001-May-13 0:10
Richard.Berry1001-May-13 0:10 
QuestionGeneric column mapping Pin
Ravikiran72p30-Apr-13 1:57
Ravikiran72p30-Apr-13 1:57 
AnswerRe: Generic column mapping Pin
Eddy Vluggen30-Apr-13 9:49
professionalEddy Vluggen30-Apr-13 9:49 
AnswerRe: Generic column mapping Pin
Mycroft Holmes30-Apr-13 13:56
professionalMycroft Holmes30-Apr-13 13:56 
AnswerRe: Generic column mapping Pin
GuyThiebaut30-Apr-13 21:49
professionalGuyThiebaut30-Apr-13 21:49 

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.