存储过程中参数如下 
@sql varchar(8000) -- 这是一个sql语句, 这个语句的where条件( id= @id)也是由程序传入的, 
@param1  --其他参数
@param2  --其他参数
...怎么执行这个过程? 我现在直接把  @sql 在程序中拼接出来
然后给 SqlParamerstring id = 1;
string sql = " SELECT * FROM Member WHERE Id = " + id.ToString();SqlParameter[] parameter = 
            { 
                new SqlParameter("@sql",SqlDbType.VarChar,8000), 
                new SqlParameter("@param1",SqlDbType.Int,4),
                .....
            }; 
parameter[0].Value = @sql;...这样做不妥啊, 求解决方法,谢谢存储过程数据库sql

解决方案 »

  1.   

    你这个应该是sql如何执行字符串型sql,参考文章http://blog.csdn.net/zxz414644665/article/details/8617828使用exec sp_executesql来执行字符串--使用Northwind数据库
    declare @sql nvarchar(200)set @sql='select * from customers'exec sp_executesql @sql
      

  2.   


    我是说怎么用.net去调用这个过程
      

  3.   

    你应该执行的是字符型的SQL语句,然后在,把参数赋值,又或者你要写一个存储过程,然后在界面对存储过程参数赋值,并执行存储过程,返回你要的datatable或者其他什么的...SqlHelper这个类库能帮到你