declare @string varchar(200),@sql varchar(1000)
set @string = ‘1,2,3,4,5,6‘
set @sql = ‘select code=‘‘‘ + replace(@string, ‘,‘, ‘‘‘ union all select ‘‘‘) + ‘‘‘‘
exec (@sql)
2023-11-30 08:19:22
declare @string varchar(200),@sql varchar(1000)
set @string = ‘1,2,3,4,5,6‘
set @sql = ‘select code=‘‘‘ + replace(@string, ‘,‘, ‘‘‘ union all select ‘‘‘) + ‘‘‘‘
exec (@sql)