Hello, I'm working on a stored procedure that feeds data into a local VB app. Something about it puzzles me though, there is a select statement that is run in "exec()"ALTER PROCEDURE [dbo].[effburstwo] @wo int,@opsq float,@fromdate varchar(25),@thrudate varchar(25),@shift char(1), @wc char(12) ASdeclare @strsqlshift varchar(65)declare @strwo varchar(8)declare @stropsq varchar(15)select @strwo=convert(varchar(8),@wo),@stropsq=convert(varchar(15),@opsq)select @strsqlshift=casewhen @shift<>'*' then "and a.wtapid='"+@shift+"'"else ""endexec("select a.wtan8,b.abalph,a.wthrw,case when a.wttyr='1' then 'RUN' when a.wttyr='2' then 'SETUP' when a.wttyr='3' then 'CANCEL' when a.wttyr='4' then 'QTY' else '*'end trantype,wtapid,wtsoqs,wtsocn,wtyst,wtdglfrom ibmprod.dbo.f31122 a, ibmprod.dbo.f0101 bwhere a.wtan8=b.aban8 and a.wtdoco="+@strwo+" and a.wtdgl between '"+@fromdate+"' and '"+@thrudate+"' and wtopsq="+@stropsq+" "+@strsqlshift+" and a.wtmcu='"+@wc+"' order by wtdgl ")Can anyone tell me why this is being executed? And pehaps if i'm lucky, why it would cause an odbc runtime error '3146' within the VB app?