Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a view to identify the shift adjustments of our employee database.

Here when I login with the admin login and run the query i get 27 records. when i login with a read-only login and run the query i only get 1 record.

any suggestion why this is happening?

this is my query

SQL
SELECT dbo.DailyAttendance.EmployeeCode AS EMP_NUMBER, dbo.ShiftAdjustment.Date AS RSD_DATE, dbo.ShiftDefinition.ShiftName AS SFT_CODE, CONVERT(VARCHAR(5), dbo.ShiftDetail.InTime, 108) AS SFT_TIMEIN, CONVERT(varchar(5), dbo.ShiftDetail.OutTime, 108) AS SFT_TIMEOUT, dbo.DailyAttendance.Date AS IOT_INDATE, CONVERT(varchar(5), dbo.DailyAttendance.InTime, 108) AS IOT_INTIME, dbo.DailyAttendance.OutDate AS IOT_OUTDATE, CONVERT(varchar(5), dbo.DailyAttendance.OutTime, 108) AS IOT_OUTTIME, dbo.ShiftDetail.LeaveDays AS SFT_LEAVEAMOUNT, CASE WHEN dbo.ShiftDetail.Midnight = 'False' THEN 0 ELSE 1 END AS SFT_MIDNIGHT FROM dbo.DailyAttendance INNER JOIN dbo.ShiftAdjustment ON dbo.DailyAttendance.EmployeeCode = dbo.ShiftAdjustment.EmployeeCode AND dbo.DailyAttendance.Date = dbo.ShiftAdjustment.Date AND YEAR(dbo.ShiftAdjustment.Date) = YEAR(GETDATE()) AND DATEPART(wk, dbo.ShiftAdjustment.Date) = DATEPART(wk, GETDATE()) + CASE WHEN datepart(dw, getdate()) <= 2 THEN - 1 ELSE 0 END INNER JOIN dbo.Shift WITH (nolock) ON dbo.ShiftAdjustment.ShiftCode = dbo.ShiftDefinition.ShiftCode INNER JOIN dbo.ShiftDetail ON dbo.DailyAttendance.DayType = dbo.ShiftDetail.DayType AND dbo.ShiftAdjustment.ShiftCode = dbo.ShiftDetail.ShiftCode WHERE (dbo.ShiftAdjustment.EmployeeCode IS NOT NULL) AND (YEAR(dbo.DailyAttendance.Date) = YEAR(GETDATE())) AND (DATEPART(wk, dbo.DailyAttendance.Date) = DATEPART(wk, GETDATE()) + CASE WHEN datepart(dw, getdate()) <= 2 THEN - 1 ELSE 0 END)
Posted
Updated 17-Jun-13 19:33pm
v2

Is your read only login defaulting to a different database? Perhaps it's reading from TEST rather than PROD, or vice versa.
 
Share this answer
 
Comments
gayanee Wijayasekara 18-Jun-13 1:42am    
In that server there is only one Employer Database and I'm running the same query in that Employer DB. although the default schema used in those two logins are different.
gayanee Wijayasekara 18-Jun-13 1:44am    
when I run the query using the Admin login my results are for the past week, When I use the read-only login my results are for the current week.
the default language of the two logins were different. by using the same default language i was able to fix this.
 
Share this answer
 
Comments
RedDk 27-Jun-13 12:20pm    
To edit an original post the poster can click on "Improve solution". Adding comments to something previously asked is customarily done by enclosing it in makeshift [edit] [/edit].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900