Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I don't think testimonials would have enticed me to become a member, or even use the site for that matter. I use the site for a learning experience..."

Geography

Where in the world do Tek-Tips members come from?
kentover (MIS)
7 Mar 11 12:02
I pull the following XML from a field in SQL Server 2008 and need to query into the string to get the values. Each attempt has returned NULL or nothing at all.

CODE

<ScheduleDefinition xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <StartDateTime xmlns="http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices">2010-11-19T15:35:00.000-06:00</StartDateTime>
    <WeeklyRecurrence xmlns="http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices">
        <WeeksInterval>1</WeeksInterval>
        <DaysOfWeek>
            <Monday>true</Monday>
            <Tuesday>true</Tuesday>
            <Wednesday>true</Wednesday>
            <Thursday>true</Thursday>
            <Friday>true</Friday>
        </DaysOfWeek>
    </WeeklyRecurrence>
</ScheduleDefinition>

The following code is used to return values. I have been able to use the code for other XML strings but this one fails. Just FYI - This is data from the SSRS Subscriptions table in the MatchData field. MSDN articles place the StartDateTime inside WeeklyRecurrence but that is not actually true.

CODE

DECLARE        @TO XML
DECLARE        @String VARCHAR(MAX)


SELECT        @TO = MatchData
FROM        [ReportServer].dbo.Subscriptions
WHERE        SubscriptionID = '9B1AF007-00AB-45E0-9C26-386E49BE926B'

SELECT        @String = @TO.value (N'(/ScheduleDefinition/StartDateTime)[1]',N'VARCHAR(MAX)')


SELECT        @String AS TEST

Thanks in advance for any help.
KO
kentover (MIS)
7 Mar 11 14:03
OK, I found the answer. It is ugly but works when you strip out the XML tags. Here is what worked.

CODE

DECLARE        @TO XML
DECLARE        @String NVARCHAR(MAX)


SELECT        @TO = REPLACE(REPLACE(CAST(MatchData AS NVARCHAR(MAX)),' xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',''),' xmlns="http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices"','')
FROM        [ReportServer].dbo.Subscriptions
WHERE        SubscriptionID = '9B1AF007-00AB-45E0-9C26-386E49BE926B'


SELECT        @String = @TO.value (N'(/ScheduleDefinition//Monday)[1]',N'VARCHAR(MAX)')


SELECT        @String AS TEST

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close