ALTER FUNCTION [dbo].[SumString] 
( 
  @userId nvarchar(40),  
  @selectName  nvarchar(4000)
) 
RETURNS nvarchar(4000) 
AS 
BEGIN 

declare @Str nvarchar(4000) 
declare @ProductName nvarchar(4000) 
set @Str =''
declare  pcurr cursor for select '"'+@selectName+'"' from  MLK_PDP.dbo.ReportView
open pcurr  
fetch next from pcurr into @ProductName  
while (@@fetch_status = 0)  
begin  
 set @Str=@Str+@ProductName
 fetch next from pcurr into @ProductName  
end  
close pcurr  

return @Str 
END 

GO

 

posted on 2012-09-25 20:48  gzh4455  阅读(217)  评论(0编辑  收藏  举报