sql, asp.net

I run the sql script and it raises error message in sql server saying
Incorrect synatx nearby 'apply'.

I also include the table structure as well as one of the value in MESSAGE table column.

Thanks,

500 points ready if any experts can resolve that...thank,
Table Columns:
EnvelopeId
Message
Status
QuoteId
CreatedDate
CreatedBy

Create procedure dbo.up_GetWebQuoteTransStatusInDetailsForDocSignAttached
(
@QuoteId INT
)
as
set nocount on
Begin

Select
      MSG.evt.value('logTime[1]', 'datetime') [logTime],
      MSG.evt.value('Source[1]', 'varchar(20)') [Source],
      MSG.evt.value('UserName[1]', 'varchar(100)') [UserName],
      MSG.evt.value('Action[1]', 'varchar(100)') [Action],
      MSG.evt.value('Message[1]', 'varchar(4000)') [Message],
      MSG.evt.value('EnvelopeStatus[1]', 'varchar(100)') [EnvelopeStatus],
      MSG.evt.value('ClientIPAddress[1]', 'varchar(100)') [ClientIPAddress],
      MSG.evt.value('Information[1]', 'varchar(100)') [Information],
      MSG.evt.value('GeoLocation[1]', 'varchar(100)') [GeoLocation]
From (Select CREATEDDATE, Cast([Message] As XML) msg FROM DocuSignEnvelopeAuditEvents
WHERE QuoteId = @QuoteId) X
Cross Apply msg.nodes('/DocuSignEnvelopeEvents/Event') As MSG(evt)
ORDER BY X.CREATEDDATE


End

Open in new window

<DocuSignEnvelopeEvents EnvelopeId="5d7f2f13-508a-4eeb-a55a-c2feeadb6505" xmlns="">
  <Event>
    <logTime>2011-03-10T11:39:42.4128057-08:00</logTime>
    <Source>API</Source>
    <UserName>John Smiths</UserName>
    <Action>Registered</Action>
    <Message>how are you</Message>
    <EnvelopeStatus>Created</EnvelopeStatus>
    <ClientIPAddress>127.1.1.1</ClientIPAddress>
    <Information />
    <GeoLocation />
  </Event>
  <Event>
    <logTime>2011-03-10T11:39:42.772183-08:00</logTime>
    <Source>API</Source>
    <UserName>Sam Chan</UserName>
    <Action>Sent Invitations</Action>
    <Message>hello</Message>
    <EnvelopeStatus>Sent</EnvelopeStatus>
    <ClientIPAddress>127.1.1.2</ClientIPAddress>
    <Information>Nothing</Information>
    <GeoLocation />
  </Event>
</DocuSignEnvelopeEvents>

Open in new window

Webboy2008Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sventhanCommented:
try this...
Table Columns:
EnvelopeId
Message
Status
QuoteId
CreatedDate
CreatedBy

Create procedure dbo.up_GetWebQuoteTransStatusInDetailsForDocSignAttached
(
@QuoteId INT
)
as
set nocount on
Begin

Select
      MSG.evt.value('logTime[1]', 'datetime') [logTime],
      MSG.evt.value('Source[1]', 'varchar(20)') [Source],
      MSG.evt.value('UserName[1]', 'varchar(100)') [UserName],
      MSG.evt.value('Action[1]', 'varchar(100)') [Action],
      MSG.evt.value('Message[1]', 'varchar(4000)') [Message],
      MSG.evt.value('EnvelopeStatus[1]', 'varchar(100)') [EnvelopeStatus],
      MSG.evt.value('ClientIPAddress[1]', 'varchar(100)') [ClientIPAddress],
      MSG.evt.value('Information[1]', 'varchar(100)') [Information],
      MSG.evt.value('GeoLocation[1]', 'varchar(100)') [GeoLocation]
From (Select CREATEDDATE, Cast([Message] As XML) msg FROM DocuSignEnvelopeAuditEvents
WHERE QuoteId = @QuoteId) X
Cross Apply msg.nodes('/DocuSignEnvelopeEvents/Event') 
ORDER BY X.CREATEDDATE


End

Open in new window

0
SharathData EngineerCommented:
Whats the SQL Server version?
0
Webboy2008Author Commented:
2005
0
SharathData EngineerCommented:
Webboy2008 - I did not get any error. I ran the same query you posted.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Webboy2008Author Commented:
Really? Then maybe it is sql 2000.
What is workaround if it is sql 2000?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.