@where=' where a=''1'' and b=''2'' and c=''3'''

解决方案 »

  1.   

    set nocount on
    declare @RecordCount int,@sql nvarchar(1000)
    set @sql='select @RecordCount=count (id) from news '+@where
    exec sp_executesql @sql,N'@RecordCount int output',@RecordCount output
      

  2.   

    N'@RecordCount int output,@RecordCount output 是什么意思 ?
      

  3.   

    请参考sp_executesql的联机帮助。
    declare @RecordCount int,
            @sql nvarchar(4000)
    set @sql='select @RecordCount=count (id) from news '+@where
    exec sp_executesql @sql,N'@RecordCount int output',@RecordCount output
    select @RecordCount
      

  4.   

    如何得到结果?在asp.net中提示出错.