BEGIN sp_executesql N'SELECT ''td''' --sp_executesql @sql,N'@StartDate DateTime,@EndDate DateTime,@End2 DateTime,@Program varchar(4)',@StartDate,@EndDate,@End2,@Program END
-- This works just fine: BEGIN -- You must have an exec before your sp_executesql or it will not work in a block exec sp_executesql N'SELECT ''td''' END
当你在一个区块中时,你不能只在没有exec的情况下调用存储过程.