November 24, 2014 at 2:53 am
SELECT @battery_included = COALESCE(@battery_included + ';', '') + CONVERT(VARCHAR(200),Item)
FROM dbo.Split(@battery,';')
help me to understand this query
November 24, 2014 at 7:31 am
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.
_______________________________________________________________
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/
November 24, 2014 at 7:39 am
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? Seems a bit pointless.
@prachisaxena201: Please provide more context.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
November 24, 2014 at 7:45 am
Koen Verbeeck (11/24/2014)
Isn't this code splitting @battery and then concatenating it back again in @battery_included? Seems a bit pointless.
Ah so it is...it does seem rather pointless.
_______________________________________________________________
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/
November 24, 2014 at 7:50 am
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.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 24, 2014 at 8:00 am
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/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply