Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

Using XML to Enhance the Performance of String Manipulations Expand / Collapse
Author
Message
Posted Tuesday, August 19, 2008 9:23 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:58 AM
Points: 5,370, Visits: 9,010
Comments posted to this topic are about the item Using XML to Enhance the Performance of String Manipulations

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
Post #555470
Posted Tuesday, August 19, 2008 9:33 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:58 AM
Points: 5,370, Visits: 9,010
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
Post #555473
Posted Tuesday, August 19, 2008 11:23 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 23, 2013 11:52 PM
Points: 20, Visits: 28
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?
Post #555503
Posted Tuesday, August 19, 2008 11:40 PM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, December 10, 2014 8:44 AM
Points: 49, Visits: 282
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
Post #555504
Posted Wednesday, August 20, 2008 12:53 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 15, 2014 4:15 AM
Points: 5,471, Visits: 1,402
Nice Article...:)


Post #555538
Posted Wednesday, August 20, 2008 3:46 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #555628
Posted Wednesday, August 20, 2008 4:37 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 5:51 AM
Points: 328, Visits: 2,001
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
Post #555646
Posted Wednesday, August 20, 2008 4:41 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, January 2, 2013 12:15 PM
Points: 1,443, Visits: 711
Excellent article... thanks!
Post #555648
Posted Wednesday, August 20, 2008 6:12 AM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, December 9, 2013 1:26 PM
Points: 60, Visits: 258
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
Post #555712
Posted Wednesday, August 20, 2008 6:28 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:58 AM
Points: 5,370, Visits: 9,010
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
Post #555718
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse