首页 > 代码库 > sql根据字符串id得到name

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

sql根据字符串id得到name