SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
ALTER     proc ViPage
@pageCount int,//总页码
@rowPage int,//当前第几页
@zdId int//条件
as
declare @sql varchar(2000)
set @sql='SELECT a.* FROM ( select top '+Convert(char(4),@pageCount) 
+' * from Visitors where zdId='+Convert(char(5),@zdId)+') a 
 LEFT JOIN (select  TOP '+Convert(char(5),@rowPage)
+' *  from Visitors where zdId='+Convert(char(5),@zdId)+') b 
ON a.VisitorID = b.VisitorID WHERE b.VisitorID IS NULL'
exec(@sql)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO我一般都这样分

解决方案 »

  1.   

    @在sql语句里面代表存储过程或者参数化操作Sql语句的参数cmd.Parmeter
      

  2.   

     System.Data.SqlClient.SqlCommand cm = new System.Data.SqlClient.SqlCommand("select * from table where ID=@ID", con);
                cm.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ID", SqlDbType.VarChar, 50, ParameterDirection.Input));
                cm.Parameters[0].Value = "111";
      

  3.   


    System.Data.SqlClient.SqlCommand cm = new System.Data.SqlClient.SqlCommand("select * from table where ID=@ID", con);
                cm.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ID", SqlDbType.VarChar, 50, ParameterDirection.Input));
                cm.Parameters[0].Value = "111";