Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 problem declaring variable in query with xmlnamesp

Author  Topic 

kamii47
Constraint Violating Yak Guru

353 Posts

Posted - 2012-09-17 : 09:20:48
I have a stored procedure in which I am reading node's data from xml data type

Now i also have to declare some variable bu always get error if declaring it

WITH XMLNAMESPACES('http://idealliance.org/Specs/mailxml12.0a/mailxml_tm' AS p3)

declare @ConsigneeApptID int
declare @PartnerId int

Please let me know what would be the problem in the syntax

Kamran Shahid
Principle Engineer Development
(MCSD.Net,MCPD.net)

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-17 : 10:01:14
You probably want to declare the variables before the WITH clause. The WITH clause by itself is not a complete statement. The cte or namespace that the WITH clause specifies should always be followed by a select/insert/delete statement outside of the WITH clause. http://msdn.microsoft.com/en-us/library/ms177400.aspx
Go to Top of Page
   

- Advertisement -