在SQL中怎么把一列字符串拆分为多列,请高手赐教

2025-05-13 14:41:45
推荐回答(1个)
回答(1):

--首先,你是按什么规则拆? 我举个例子 你要按字段中的逗号拆开,假设字段名叫text
--用charindex和substring这2个函数   
select   substring(text,1,charindex(',',text)-1) as  [before],  substring(text,charindex(',',text),len(text)) as  [after]     from table