I am inserting data from an XML string into a SQL Server 2000 table. I have no way to assure that the data I assume is numeric coming in via XML is in fact numeric. So it is causing my insert to fail. Here is the insert statement:
BookQty is defined in my table as an integer (I can't change the table definition) and the BookQty coming in from the XML string is supposed to be numeric, but apparently isn't always numeric. Is there a way I can put a conditional statement (if, case, etc) in the insert statement to say if it is numeric then use the value otherwise insert a 0 into BookQty. (Note: The above insert statement is abbreviated. There are actually a bunch of numeric fields that I need to check, which is why I was wondering if I could check right in the insert statement instead of doing something like inserting the data into a temp table and checking there).
Thanks
-Mike
Code:
INSERT into sm_InvBalanceRoot
(LocCd,
CatCd,
BookQty)
SELECT
LocCd,
CatCd,
BookQty
FROM OPENXML (@xmlHandle, '/Record') WITH
(LocCd varchar(20) './LocCd',
CatCd varchar(20) './CatCd',
BookQty varchar(20) './BookQty')
BookQty is defined in my table as an integer (I can't change the table definition) and the BookQty coming in from the XML string is supposed to be numeric, but apparently isn't always numeric. Is there a way I can put a conditional statement (if, case, etc) in the insert statement to say if it is numeric then use the value otherwise insert a 0 into BookQty. (Note: The above insert statement is abbreviated. There are actually a bunch of numeric fields that I need to check, which is why I was wondering if I could check right in the insert statement instead of doing something like inserting the data into a temp table and checking there).
Thanks
-Mike