|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
XML Boolean value to SQL Server BIT
I am working on an application written in Visual FoxPro 7 that produces an XML file of a recordset. One of the fields in this XML file is type="xsd:boolean" with a value of "false". My application then calls a SQL Server stored procedure that does a bulk update using this XML file(converted to a stream) and OPENXML(). Unfortunately, the corresponding field in the SQL database is BIT. When I run the stored procedure I get an error: Syntax error converting the nvarchar value 'false' to a column of datatype BIT. The XML stream has schema information that clearly defines this field as BOOLEAN.
How can I get around this datatype inconsistency - type conversions,etc. |
|
#2
|
||||
|
||||
|
You could always convert it on the fly:
Code:
Function Bool2Bit(bool_Value) Select Case bool_Value Case True Bool2Bit = 1 Case False Bool2Bit = 0 End Select End Function Now you can embed this in your SQL string construction: Code:
str_SQL = "INSERT INTO Database (TrueOrFalse) VALUES (" & Bool2Bit(xml_BooleanValue) & ");"
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > XML Boolean value to SQL Server BIT |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|