DECLARE @Counts INT EXEC sp_executesql N'select @Counts=count(1) from tbName',N'@Counts int out',@Counts OUT SELECT @Counts