Click here to Skip to main content
16,009,343 members
Home / Discussions / Database
   

Database

 
AnswerRe: difference between with and temp table in my two query Pin
Jörgen Andersson8-May-13 11:52
professionalJörgen Andersson8-May-13 11:52 
AnswerRe: difference between with and temp table in my two query Pin
Fabricio Dos Santos Antunes10-May-13 14:55
Fabricio Dos Santos Antunes10-May-13 14:55 
QuestionExport Image from SQL to png Format Pin
mrfalk7-May-13 8:09
mrfalk7-May-13 8:09 
AnswerRe: Export Image from SQL to png Format Pin
Eddy Vluggen7-May-13 9:52
professionalEddy Vluggen7-May-13 9:52 
QuestionBulk insert not recognizing end of file Pin
searching for solution.....5-May-13 23:18
searching for solution.....5-May-13 23:18 
AnswerRe: Bulk insert not recognizing end of file Pin
Eddy Vluggen6-May-13 7:56
professionalEddy Vluggen6-May-13 7:56 
QuestionHow to get data from Gridview (gridview(checkbox)) using asp.net and c#...... Pin
nukalarajesh1-May-13 21:19
nukalarajesh1-May-13 21:19 
AnswerRe: How to get data from Gridview (gridview(checkbox)) using asp.net and c#...... Pin
Richard MacCutchan1-May-13 21:27
mveRichard MacCutchan1-May-13 21:27 
AnswerRe: How to get data from Gridview (gridview(checkbox)) using asp.net and c#...... Pin
AANIL DHAKAD8-May-13 3:17
AANIL DHAKAD8-May-13 3:17 
Questionhow to upload a iamge file on web server in mvc4 asp.net c# Pin
nukalarajesh1-May-13 21:06
nukalarajesh1-May-13 21:06 
QuestionSQL Server null date 01/01/1900 possible issue - a question Pin
GuyThiebaut1-May-13 5:51
professionalGuyThiebaut1-May-13 5:51 
AnswerRe: SQL Server null date 01/01/1900 possible issue - a question Pin
Richard Deeming1-May-13 6:04
mveRichard Deeming1-May-13 6:04 
GeneralRe: SQL Server null date 01/01/1900 possible issue - a question Pin
Aner Bautista3-May-13 8:25
Aner Bautista3-May-13 8:25 
GeneralRe: SQL Server null date 01/01/1900 possible issue - a question Pin
jschell3-May-13 11:24
jschell3-May-13 11:24 
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 

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.