I am facing a problem while i pass xml as an intput to stored procedure.
The problem is that there are ceratin special characters which when used as a part of xml give error.Like the input which i give to my sp is :
Declare @.XMLString XML
Set @.XMLString = N'<Company CompanyName = "Hilary Group & Sons" Code = "HGS" >
</Company>'
Exec sproc_Insert_Company @.XMLString
The error which i get on execution is: Msg 9421, Level 16, State 1, Line 2
XML parsing: line 2, character 34, illegal name character..
Its being generated because of the '&' being used in CompanyName.
In my sp i m using it as : .
Insert Into Company(
CompanyName,
Code,
)
Output Inserted.CompanyId Into @.tbl
-- TurnOver,
-- NetIncome,
-- YrOfIncorporation,
SELECT
CompanyName = ParamValues.Item.value( '@.CompanyName' , 'varchar(101)'),
Code = ParamValues.Item.value( '@.Code' , 'varchar(6)'),
FROM @.XMLString.nodes('Company') AS ParamValues(Item)
Its not only this but there are other special characters which create problem like '@.' and many more...
How to resolve it?
plzz do help at the earliest...
The ampersand is a "special" character.
Here is an article about this and how to handle it: http://www.xml.com/pub/a/2001/01/31/qanda.html
|||Thanx a lot Louis....
u saved me from a big problem and that too on time....
Thanx once again..today i understood the power of microsoft forums...its been really helpful to me..
|||i dont know how to close a thread or mark it as answered..i dont find any tab which says that my post has been answered...
|||I done it for you.|||Thanx

No comments:
Post a Comment