|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 10:50 AM
Points: 6,367,
Visits: 8,227
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 10:50 AM
Points: 6,367,
Visits: 8,227
|
|
Hey all...
I don't know how it happened, but the code in the article is missing some spaces from what I submitted. They should be pretty obvious where that is, but if you are having problems let me know and I'll post how it should be (or get Steve or someone to add them to the article).
The biggest offenders: space needed between "use" and "AdventureWorks" space needed between "set" / "select" / "declare" / "print" / "if" and the rest of the command. space needed between "FOR" and "XML" space needed between "XML" and "PATH"
Wayne
Wayne Microsoft Certified Master: SQL Server 2008 If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it! Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines, CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, August 29, 2011 8:12 PM
Points: 20,
Visits: 27
|
|
I agree with you wayne.
I have a small issue in addition to that, this line gave me error:
select @MyXMLString = @MyXMLString + ' '+ AccountNumber + ' '
This is the error:
Msg 102, Level 15, State 1, Line 6 Incorrect syntax near 'AccountNumber'.
Any idea?
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, April 29, 2013 10:28 AM
Points: 46,
Visits: 262
|
|
Great article, this may solve the problem I had with this code that would have been considerably faster than Coalesce.
-- create list to pivot hist data SELECT @DistList = COALESCE(@DistList + ',[', '[') + CAST(Dist AS VarCHAR(85)) + ']' FROM ( SELECT top 1000 Disty FROM @t1 Order by Disty ) t(Dist) -- try for XML to speed up the coalesce -- may bug on Shangai P&S --Select @DistList = ( --SELECT Disty + ', ' As [text()] -- FROM @t1 -- ORDER BY Disty -- FOR XML PATH('') --) --Set @DistList = LEFT(@DistList, Len (@DistList) -1)
BI Guy
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Thursday, May 16, 2013 2:50 AM
Points: 4,786,
Visits: 1,334
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, September 12, 2008 12:17 AM
Points: 3,
Visits: 8
|
|
Hi, Why would you prefer to build XML strings manually when you can do it with FOR XML statement. The very purpose of FOR XML statement would be void otherwise.
Thanks and regards Anil
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Friday, May 03, 2013 2:54 AM
Points: 328,
Visits: 1,848
|
|
WayneS (8/19/2008) Hey all...
I don't know how it happened, but the code in the article is missing some spaces from what I submitted.
Seems to be happening on other articles too, I noticed it on this one yesterday: http://www.sqlservercentral.com/articles/Integration+Services/63623/
although that one also suffers from the code sections being strangely fragmented
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Wednesday, January 02, 2013 12:15 PM
Points: 1,443,
Visits: 711
|
|
| Excellent article... thanks!
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:07 PM
Points: 60,
Visits: 257
|
|
anil_mootha (8/20/2008) Hi, Why would you prefer to build XML strings manually when you can do it with FOR XML statement. The very purpose of FOR XML statement would be void otherwise.
Thanks and regards Anil
I'm also interested in knowing the answer to Anil's question. Have a great day.
Paul DB
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 10:50 AM
Points: 6,367,
Visits: 8,227
|
|
JPJ (8/19/2008) I agree with you wayne.
I have a small issue in addition to that, this line gave me error:
select @MyXMLString = @MyXMLString + ' '+ AccountNumber + ' '
This is the error:
Msg 102, Level 15, State 1, Line 6 Incorrect syntax near 'AccountNumber'.
Any idea?
(I do wish that this site's forum board would support the display of XML tags easier!)
For that select command, there are two extraneous quote marks. The first is on the second line, after the "Row" xml tag immediately prior to the "AccountNumber" tag. The second is on the third line, immediately after the backslash character and immediately prior to the "AccountNumber" tag.
So, it should look like: select @MyXMLString = @MyXMLString + '<Row><AccountNumber>'+ AccountNumber + '</AccountNumber></Row>'
Wayne Microsoft Certified Master: SQL Server 2008 If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it! Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines, CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
|
|
|
|