exec sp_executesql N'
select CommonPoint+(OutputValue*0.01) as ''AllPoint'',
(OutputValue*0.01) as ''OutputConvertValue'', AwardOrPunishment ,
CommonPoint ,
OutputValue ,
PR. RulesID ,
RulesName ,
RulesOrderNumber ,
RulesType ,
Unit, isnull(Cnt,0) as ''Cnt''
from dbo.PointRules PR
left join dbo.UserRecordDetails B on PR.RulesID = B.RulesID
and B.RecordID= (select RecordID from dbo.UserRecord where
CreateDate=''@p0'' and RecordUser=''@p1'')',
N'@p0 datetime,@p1 nvarchar(3)',@p0='2015-07-08',@p1=N'253'
select CommonPoint+(OutputValue*0.01) as 'AllPoint',
(OutputValue*0.01) as 'OutputConvertValue', AwardOrPunishment ,
CommonPoint ,
OutputValue ,
PR. RulesID ,
RulesName ,
RulesOrderNumber ,
RulesType ,
Unit, isnull(Cnt,0) as 'Cnt'
from dbo.PointRules PR
left join dbo.UserRecordDetails B on PR.RulesID = B.RulesID
and B.RecordID= (select RecordID from dbo.UserRecord where
CreateDate='2015-07-08' and RecordUser='253')
下面的OK,上面 就报错!
不要使用双引号
Database.SqlQuery <class>(@"where RecordUser={0} and r.CreateDate={1} ",model.RecordUser,model.CreateDate)
本来 {0} {1} l两侧 都有 加上 单引号的。 去掉了 果然 ok!