alter function F_GetUserPostion(@userName varchar(120)) returns varchar(600)
as
begin


Declare curGetUserPostion Cursor
    for
select (select column_Name from Hr_Professional where Column_id=Hr_Intention.GSsortID) from Hr_Intention where GuserName=@userName 

  Declare @ColumnName  varchar(120)
  Declare @body  varchar(600)

--初始化

  Set @body=''
set  @ColumnName=''

  --打开游标
  Open curGetUserPostion

  --循环并提取记录
  Fetch Next From curGetUserPostion Into @ColumnName  
  While ( @@Fetch_Status=0 )  
  begin
--更新到汇总表。
set @body = @body+'-'+@ColumnName
  
Fetch Next From curGetUserPostion Into @ColumnName  
     

end
  --关闭游标  
  Close curGetUserPostion
  --释放游标
  Deallocate curGetUserPostion
return @body
end

posted on 2008-12-17 14:59  bestsaler  阅读(125)  评论(0编辑  收藏  举报