存储过程 列名 如何作为参数传值 用游标实现

 declare @result nvarchar(80)--用来处理结果的变量
 begin
 --声明一个游标
  Declare curStudentFee Cursor for
  SELECT convert(bigint,[学籍号]) FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;IMEX=2;DATABASE=F:\ExcelFiles\二年级语文.xls',Sheet1$);---查询语句(查询所有用户存储过程名称)这个是我指定的excel的某一列 可以是查询的某一个表的指定列
  
   --打开游标
  Open curStudentFee
  --循环并提取记录
  Fetch Next From curStudentFee Into @result --取第一条记录存入@result中
  While ( @@Fetch_Status=0 )  
        begin
        print ''''+@result+''''+',';---处理结果
     Fetch Next From curStudentFee into @result----下一条
       end
  --关闭游标  
   Close curStudentFee
  --释放游标
 Deallocate curStudentFee
 end

posted @ 2014-01-18 10:04  牡丹  阅读(213)  评论(0)    收藏  举报