Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-05-07 : 07:32:00
|
destination Table schemaPlan_id intlocation_id intuser_id intmy data is coming as below '72|12,35,68,17,16$40|12,43,38',1 where 72 is the plan id and next are the location_id and new row data is splited with & last input is created by .need to create sp for insert into tableTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-07 : 07:38:46
|
your explanation doesnt make sense. & doesnt even appear in your sample datawhich all of above values will fall into location field and which all into user_id field?also I assume each rows needs to be split up to multiple rows in table.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-05-07 : 08:26:21
|
looking for the below output ::Plan Id--- location ID--- UserID72 ---12---172 ---35---172 ---68---172 ---17---172 ---16---140 ---12---140 ---43---140 ---38---1THANKSSHANMUGARAJnshanmugaraj@gmail.com |
 |
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-05-07 : 09:10:06
|
Declare @s Varchar(100) = '72|12,35,68,17,16$40|12,43,38'Select * into #Temp From dbo.Split('72|12,35,68,17,16$40|12,43,38','$')Select SUBSTRING(items,0,CHARINDEX('|',items,0)) Item,SUBSTRING(items,CHARINDEX('|',items,0)+1,LEN(items)) Valueinto #temp1 From #Temp ASelect A.Item 'PlanID',B.items 'LocationID',1 'UserID' From #temp1 ACross Apply(Select * From dbo.Split(A.Value,','))BDrop table #Temp,#temp1THANKSSHANMUGARAJnshanmugaraj@gmail.com |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|