SQL LIKE反用

 USE [ECDev]
GO
/****** Object:  UserDefinedFunction [dbo].[sumDepartmentNameToString]    Script Date: 10/17/2011 20:04:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Alter function [dbo].[GetTeamNamesSql]
(
   @DepartmentIDs varchar(max)--部门ID字符串
)
Returns nvarchar(max)
as  
 begin 
          declare @DepartmentNames varchar(max)
          SELECT @DepartmentNames=
          case when @DepartmentNames is null then [Name] else @DepartmentNames+','+[Name] end
          from Pcitc_PC_Department_T
          where @DepartmentIDs like '%'+convert(varchar(50),ID)+'%'
          return @DepartmentNames 
 end

 

 

 

select USEUnIT,dbo.GetTeamNamesSql(USEUnIT) as DepartmentNames from ec_tevaluationReport

摘自电子商务ECDev数据库

阅读更多
个人分类: SQL
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭