| Author |
Topic |
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-07-23 : 11:44:58
|
So i have a table with these values:CFSID AbuseTypeIDs989891 1929,1312,8789787871 1929, 1987, 2322643244 1879 What i need to do is break out those AbuseTypeIDs where that column has ONE value only, no commas, still associated with the same CFSID value. So it should look like this:[code]CFSID AbuseTypeIDs989891 1929989891 1312989891 8789787871 1929787871 1987787871 2322643244 1879[code]so how do i accomplish this? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-07-23 : 12:02:47
|
| The parsing you're suggesting doesn't really apply because it uses a different ID for each row. I need to rows to duplicate the CFSID value to match with each AbuseTypeIDs value in that column. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-23 : 12:09:12
|
quote: Originally posted by WJHamel The parsing you're suggesting doesn't really apply because it uses a different ID for each row. I need to rows to duplicate the CFSID value to match with each AbuseTypeIDs value in that column.
thats not an issue. you just need to select ID from you main table not from functionyou just need to create function and use it like belowSELECT t.CFSID,f.ValFROM yourtable tCROSS APPLY dbo.ParseValues(t.AbuseTypeIDs) f try it and you'll see what i mean------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-07-23 : 21:54:29
|
| For some reason, i'm getting the following error when trying to apply the function against that table:Msg 313, Level 16, State 3, Line 3An insufficient number of arguments were supplied for the procedure or function dbo.ParseValues.Using my table name in the query looks like this:SELECT t.CFSID,f.ValFROM douglasconversion.dbo.victimdescriptors tCROSS APPLY dbo.ParseValues(t.AbuseTypeIDs) f |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-23 : 22:18:55
|
quote: Originally posted by WJHamel For some reason, i'm getting the following error when trying to apply the function against that table:Msg 313, Level 16, State 3, Line 3An insufficient number of arguments were supplied for the procedure or function dbo.ParseValues.Using my table name in the query looks like this:SELECT t.CFSID,f.ValFROM douglasconversion.dbo.victimdescriptors tCROSS APPLY dbo.ParseValues(t.AbuseTypeIDs,',') f
oops sorry there was a typo.use modified suggestion as above------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-07-24 : 06:05:04
|
| I know it's going to be a GREAT day when the error was not mine, but Visakhs! ;-) Thanks as usual. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-24 : 09:32:14
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|