declare @P1 int set @P1=-1 exec sp_prepare @P1 output, <===== P1 is declared OUTPUT, you use a @ prefix ? N'@P1 text', <===== P1 is declared text ! N'SELECT tblTest.ID, tblTest.TextField1, tblTest.TextField2, FROM tblTest WHERE tblTest.SegmentID = @P1 ', 1 <===== P1 text is compared select @P1 <===== P1 outputFabio