sql根据字符串id得到name

//根据一个以逗号分隔的字符串,查出一张表的 Name 用逗号分隔
 CREATE function [dbo].[function_name](@platformids nvarchar(200))
  returns varchar(180)
AS

BEGIN

declare @name varchar(180);

select @name=stuff((select ','+c.PlatformName from
 (SELECT a.Value,b.PlatformName FROM dbo.fn_Split1(@platformids,',')
  AS a INNER JOIN dbo.Order_PlatformTable AS b on b.id=a.Value) AS c for xml path ('')),1,1,'')

return @name;

END

posted @ 2017-02-28 18:36  Jesh_95  阅读(794)  评论(0编辑  收藏  举报