sql - TSQL XML Parsing / Insert -


i passing xml stored procedure , inserting table. if passing multiple nodes, of happening before gets something else comment?

for example, if xml contained 6 vehicle nodes, insert statement run 6 times. of run before reaching something else line?

the reason ask because want insert data xml separate table using lastinsertedid code below.

can done?

insert licenseplates (carcolor, carmodel, licenseplate, empid, dateadded)                 select  paramvalues.x2.value('color[1]', 'varchar(100)'),                         paramvalues.x2.value('model[1]', 'varchar(100)'),                         paramvalues.x2.value('licenseplate[1]', 'varchar(100)'),                         @empid,                         getdate()                   @xmldata.nodes('/vehicles/vehicle') paramvalues(x2)                   --something else 

yes. 6 rows inserted before code hits -- else line.

so if want capture 6 ids , insert audit table or foreign key table, use inserted table so.

insert dbo.sampletable_audit  (lastinsertedid, .....)     select id, .... inserted; 

(pseudocode, idea.)


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -