0
對於更新海量記錄,我使用了xml查詢。從前端(C#.net)填充xml並將其作爲參數傳遞給存儲過程(如@Master_rows_xml_Update
)。SQL Server 2005中的XML查詢錯誤
我面對的情況。當我在存儲過程中
declare @i INTEGER,@Master_rows_xml_Update XML;
SET @Master_rows_xml_Update= '<root>
<row Id="1" FinYearId="5" EmployeeId="55" EnteredOn="7/1/2011 12:00:00 AM" EnteredBy="1" HouseRentPaid="False" HouseRentAmount="3500.00" officeId="9"/>
<row Id="2" FinYearId="5" EmployeeId="55" EnteredOn="7/1/2011 12:00:00 AM" EnteredBy="1" HouseRentPaid="False" HouseRentAmount="3500.00" officeId="9"/>
</root>';
exec sp_xml_preparedocument @i output, @Master_rows_xml_Update;
update EmployeeFinYearInvestment
set EmployeeFinYearInvestment.FinYearId = ox.FinYearId,
EmployeeFinYearInvestment.EmployeeId = ox.EmployeeId,
EmployeeFinYearInvestment.EnteredOn = ox.EnteredOn,
EmployeeFinYearInvestment.EnteredBy = ox.EnteredBy,
EmployeeFinYearInvestment.HouseRentPaid = ox.HouseRentPaid,
EmployeeFinYearInvestment.HouseRentAmount = ox.HouseRentAmount,
EmployeeFinYearInvestment.officeId=ox.officeId
from OpenXml(@i, 'root/row')
with (Id INT,FinYearId INT, EmployeeId INT,EnteredOn DATETIME,EnteredBy INT , HouseRentPaid BIT,HouseRentAmount DECIMAL ,officeId INT) ox
where EmployeeFinYearInvestment.Id = ox.Id;
exec sp_xml_removedocument @i;
..它不能更新ACTION見下表去爲這個命令
程序也不會返回任何錯誤...
任何想法...
謝謝.. Anirban
您是否試圖調試此代碼?它如何選擇XML?是否存在來自'EmployeeFinYearInvestment.Id = ox.Id;'子句的項目? – VMAtm