Receiving this fault message
Msg 8169, Level 16, State 2, Line 6
Conversion failed when converting from a character string to uniqueidentifier.
when executing this string.
DECLARE
@StartDate date =getdate() -- '2014-9-04'
DECLARE
@EndDate date = getdate() +1--'2014-9-05'
Declare
@ToteID int = 3821696 -- Or, specify a tote #
SELECT
toteid, PimsFacilityId, f.Name as Facility, c.Name as Cart, t.Created, t.Updated as verified, u.UserName as VerifiedBy
FROM
px_Tote t(nolock) INNER JOIN
px_BatchDetail bd
(nolock) ON t.BatchDetailId = bd.BatchDetailId INNER JOIN
px_MedPass mp
(nolock) ON bd.MedPassId = mp.MedPassId INNER JOIN
px_Cart c
(nolock) ON mp.CartId = c.CartId INNER JOIN
px_Facility f
(nolock) ON c.FacilityId = f.FacilityId
LEFT
OUTER JOIN aspnet_Users u on u.UserId = t.UpdatedBy
where
((@ToteID =0 and t.Created > @startdate and t.Created < @Enddate) or ToteId = @ToteID) and t.IsVerified=1
What is wrong?