I think this should do it:create proc publicPoemOfTheDay@PoemID int outputasselect top 1 @PoemID = PoemIDFROM dbo.Poemswhere PoemOfTheDay=1 and PoemArchive=0ORDER By NEWID()SELECT PoemID ,PoemName ,Author ,PoemText ,ImageType ,cast(PoemID as varchar)+ '.' + ImageType as PoemIllustrationFROM dbo.Poemswhere PoemID = @PoemIDgodeclare @pid intexec publicPoemOfTheDay @PoemID = @pid outputselect @pid
Be One with the OptimizerTG