sqlserver 版本大于2016用 where itme_type in (select * from SELECT value FROM STRING_SPLIT(@je_bb,',')
小于2016版本 需要调用自定义函数
- CREATE FUNCTION [dbo].[Split]
- (
- @c VARCHAR(MAX) ,
- @split VARCHAR(50)
- )
- RETURNS @t TABLE ( col VARCHAR(50) )
- AS
- BEGIN
- WHILE ( CHARINDEX(@split, @c) <> 0 )
- BEGIN
- INSERT @t( col )
- VALUES ( SUBSTRING(@c, 1, CHARINDEX(@split, @c) - 1) )
- SET @c = STUFF(@c, 1, CHARINDEX(@split, @c), '')
- END
- INSERT @t( col ) VALUES ( @c )
- RETURN
- END
- GO
复制代码 |