GilaMonster (11/24/2014)
Koen Verbeeck (11/24/2014)
Sean Lange (11/24/2014)
prachisaxena201 (11/24/2014)
SELECT @battery_included = COALESCE(@battery_included + ';', '') + CONVERT(VARCHAR(200),Item)FROM dbo.Split(@battery,';')
help me to understand this query
It looks like you have a delimited string in a variable named @battery which you are splitting and storing the last value in the result set to @battery_included. This seems like not a good approach to me but without the code for dbo.Split it is impossible to say.
Isn't this code splitting @battery and then concatenating it back again in @battery_included?
Assuming Split does what it's name implies, yes.
Another big assumption but I am guess it is using the DelimitedSplit8K since the name referenced is Item.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/