一道存储过程面试题
users1
name company company_address url1
Joe ABC Work Lane abc.com;xyz.com
Jill XYZ Job Street abc.com;xyz.com
写存储过程来创建新表
users2
name company company_address url1
Joe ABC Work Lane abc.com
Joe ABC Work Lane xyz.com
Jill XYZ Job Street abc.com
Jill XYZ Job Street xyz.com
要是分不够还可以再加。还有别的小问题要提问
------解决方案--------------------把url1 按分號(;)拆成多筆紀錄??
------解决方案--------------------create proc up_test
as
select * into user2
from (
select name,company,company_address,left(url1,charindex( '; ',url1)-1) as url1
from user1
union all
select name,company,company_address,right(url1,len(url1)-charindex( '; ',url1))
from user1)t