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.
| Author |
Topic |
|
sqlyukon
Starting Member
8 Posts |
Posted - 2006-06-29 : 14:10:27
|
| Please execute the below script- and help me get the desired results as suggested at the bottom.Thanks.CREATE PROCEDURE dbo.AppTransXMLInsert ( @xml_text text )ASSET NOCOUNT ONBEGIN DECLARE @i int -- create internal representation of the document EXEC sp_xml_preparedocument @i OUTPUT, @xml_text BEGIN TRAN SELECT ApplicationID , TransactionID , BrowserID FROM OPENXML(@i, '/MyApp/AppTrans',2) WITH ( ApplicationID int, TransactionID int, BrowserID int '../@BrowserID' ) IF @@ERROR <> 0 BEGIN RAISERROR('Error occured while populating', 16, 1) ROLLBACK RETURN END COMMIT TRAN -- cleanup: EXEC sp_xml_removedocument @i --SELECT * FROM ScriptHealth -- return success RETURN 0ENDGOExec dbo.AppTransXMLInsert'<MyApp> <BrowserIndicator>2</BrowserIndicator> <BrowserID>5</BrowserID> <BrowserName>Order</BrowserName> <BrowserVersion>1212</BrowserVersion> <AppTrans> <ApplicationID>1</ApplicationID> <ApplicationName>Demo Application</ApplicationName> <TransactionID>1</TransactionID> <TransactionName>Transaction1</TransactionName> </AppTrans> <AppTrans> <ApplicationID>1</ApplicationID> <ApplicationName>Demo Application</ApplicationName> <TransactionID>2</TransactionID> <TransactionName>Transaction2</TransactionName> </AppTrans></MyApp>'/*Results --------ApplicationID TransactionID BrowserID1 1 NULL1 2 NULLDesired Results ----------------ApplicationID TransactionID BrowserID1 1 51 2 5 |
|
|
mandm
Posting Yak Master
120 Posts |
Posted - 2006-06-29 : 15:20:18
|
| Change your select query to this.SELECT ApplicationID ,TransactionID ,BrowserID FROM OPENXML(@i, '/MyApp/AppTrans',2) WITH (ApplicationID int,TransactionID int,BrowserID int '../BrowserID' |
 |
|
|
|
|
|
|
|