My first stored procedure (in sql-server). I’m not able to make it work, it raises a warning in a.Id
After reading, and not really understand much, I’m not even sure if I can use this inner join inside a stored procedure.
select top 1 b.*, a.*
FROM Bids b
INNER JOIN Auctions a
ON b.Auction_Id = a.Id
(NOLOCK) WHERE ( a.Ends IS NOT NULL AND a.Starts IS NOT NULL AND a.Starts < @Now AND a.Ends > @Now)
ORDER BY b.CreationTime DESC
Actually, I’ll need just b.* but I assume I have to retrieve all the fields?.
Thanks
Change the locking hint to this:
Full query would be: