I am using the following query to bind a datagrid
SELECT OutOfCell.CurrentBookingNb
r, OutOfCell.FullName, OutOfCell.Location, OutOfCellRecords.OfficerNb
r, OutOfCellRecords.Time
FROM (SELECT TOP (100) PERCENT dbo.Inmate.CurrentBookingN
br, dbo.Inmate.InmateLastName + N', ' + dbo.Inmate.InmateFirstName
AS FullName,
OutOfCell_1.Name AS Location, MAX(dbo.OutOfCellLog.DateT
ime1) AS DateTime, dbo.Cell.CellNbr, dbo.Section.SectionName,
dbo.Section.SectionNbr
FROM dbo.Inmate INNER JOIN
dbo.OutOfCell AS OutOfCell_1 ON dbo.Inmate.OutofCellID = OutOfCell_1.OutOfCellID INNER JOIN
dbo.OutOfCellLog ON dbo.Inmate.CurrentBookingN
br = dbo.OutOfCellLog.BookingNb
r INNER JOIN
dbo.OutOfCellDetails ON dbo.OutOfCellLog.OutOfCell
LogUID = dbo.OutOfCellDetails.OutOf
CellLogUID
INNER JOIN
dbo.Cell ON dbo.Inmate.CellID = dbo.Cell.CellID INNER JOIN
dbo.Section ON dbo.Cell.SectionNbr = dbo.Section.SectionNbr
GROUP BY dbo.Inmate.CurrentBookingN
br, dbo.Inmate.InmateLastName + N', ' + dbo.Inmate.InmateFirstName
, OutOfCell_1.Name, dbo.Cell.CellNbr,
dbo.Section.SectionName, dbo.Section.SectionNbr
ORDER BY FullName) AS OutOfCell INNER JOIN
(SELECT OutOfCellLog_1.BookingNbr,
OutOfCellLog_1.OfficerNbr,
CASE WHEN OutOfCellDetails_1.Name NOT LIKE '%*%' THEN CONVERT(Char(5),
DateTime1, 108) ELSE Substring(OutOfCellDetails
_1.Name, 0, 3) + CONVERT(Char(5), DateTime1, 108) END AS Time,
MAX(OutOfCellLog_1.DateTim
e1) AS DateTime
FROM dbo.OutOfCellLog AS OutOfCellLog_1 INNER JOIN
dbo.OutOfCellDetails AS OutOfCellDetails_1 ON OutOfCellLog_1.OutOfCellLo
gUID = OutOfCellDetails_1.OutOfCe
llLogUID INNER JOIN
(SELECT TOP (100) PERCENT OutOfCellLog_1.BookingNbr,
MAX(OutOfCellLog_1.DateTim
e1) AS DateTime
FROM dbo.OutOfCellLog AS OutOfCellLog_1 INNER JOIN
dbo.OutOfCellDetails AS OutOfCellDetails_1 ON
OutOfCellLog_1.OutOfCellLo
gUID = OutOfCellDetails_1.OutOfCe
llLogUID INNER JOIN
dbo.Inmate AS Inmate_1 ON OutOfCellLog_1.BookingNbr = Inmate_1.CurrentBookingNbr
WHERE (OutOfCellDetails_1.TransI
NorOUT LIKE N'%To%') AND (OutOfCellLog_1.OfficerNbr
IS NOT NULL)
GROUP BY OutOfCellLog_1.BookingNbr
HAVING (OutOfCellLog_1.BookingNbr
IS NOT NULL)
ORDER BY OutOfCellLog_1.BookingNbr DESC, DateTime DESC) AS inmates ON OutOfCellLog_1.BookingNbr = inmates.BookingNbr AND
OutOfCellLog_1.DateTime1 = inmates.DateTime
WHERE (OutOfCellDetails_1.TransI
NorOUT LIKE N'%To%')
GROUP BY OutOfCellLog_1.BookingNbr,
OutOfCellLog_1.OfficerNbr,
CASE WHEN OutOfCellDetails_1.Name NOT LIKE '%*%' THEN CONVERT(Char(5),
DateTime1, 108) ELSE Substring(OutOfCellDetails
_1.Name, 0, 3) + CONVERT(Char(5), DateTime1, 108) END
HAVING (OutOfCellLog_1.BookingNbr
IS NOT NULL) AND (OutOfCellLog_1.OfficerNbr
IS NOT NULL)) AS OutOfCellRecords ON
OutOfCell.CurrentBookingNb
r = OutOfCellRecords.BookingNb
r AND OutOfCell.DateTime = OutOfCellRecords.DateTime
WHERE (OutOfCell.SectionNbr LIKE '%')
However whenever I try to do that it comes up with the following error
"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
"
Any help would be appreciated.
Thanks,
Aditya
Start Free Trial