int CurrentPage=3;
strSQL.Format("SELECT TOP 32 SID FROM Equipment WHERE (SID NOT IN (SELECT TOP 32*'%d' SID FROM Equipment group by SID  ORDER BY SID)) group by SID ORDER BY SID",CurrentPage);
m_pRecordset=m_pConnection->Execute((_bstr_t)strSQL,NULL,adCmdText);//select * from History_Record authorsstrSQL.Format("SELECT TOP 32 SID FROM Equipment WHERE (SID NOT IN (SELECT TOP 32*'%d' SID FROM Equipment group by SID  ORDER BY SID)) group by SID ORDER BY SID",CurrentPage);

执行当前语句错误???

解决方案 »

  1.   

    SELECT TOP 32*'%d'
    这是神马玩意?
    还是写个好点的SQL语句吧
    这个即使勉强成功,后期维护也是问题
      

  2.   


    int CurrentPage=32;
    strSQL.Format("SELECT TOP 32 SID FROM Equipment WHERE (SID NOT IN (SELECT TOP %d SID FROM Equipment group by SID  ORDER BY SID)) group by SID ORDER BY SID",CurrentPage*2);上面语句如何用SQL语句实现?
      

  3.   


    declare    @CurrentPage int 
    declare    @TotalPage int
    declare @strsql nvarchar(200)
    set @CurrentPage=32
    set @TotalPage=32
    set @strsql='SELECT TOP'+str(@CurrentPage)+' sid FROM equipment WHERE (SID NOT IN (SELECT TOP ' +str(@TotalPage)+' SID FROM Equipment group by SID  ORDER BY SID))group by SID ORDER BY SID'
    exec(@strsql)
    go
      

  4.   

    [code=SQL]
    select getdate()
    SELECT TOP 12 RecordDate FROM History_Record WHERE ( RecordDate>='2011-05-29 00:00:00:000' and RecordDate<='2011-05-29 23:59:59:000' and 
    RecordDate
    NOT IN (SELECT TOP 24 RecordDate FROM History_Record Where RecordDate>='2011-05-29 00:00:00:000' and RecordDate<='2011-05-29 23:59:59:000' ORDER BY RecordDate))
    ORDER BY RecordDate
    select getdate()
    code]
    查询时间竟然有2秒??