Nick
07/11/2022, 3:09 PMWHERE SomeBitCol = <cfqueryparam cfsqltype="bit" value="true">
or
Option 2: WHERE SomeBitCol = 1
(To be clear, this is not a variable. 1/true would be passed as a hard-coded value. If it was a variable, I'd definitely use <cfqueryparam>
)sknowlton
07/11/2022, 3:16 PMqb
and let it solve this for you. 🙂 but I'd always use cfqueryparam, and if you're using it anyway, there's no 'better' with respect to what kind of 'truthy' value it getsNick
07/11/2022, 3:20 PMqb
into the stack... but until then, <cfqueryparam>
it is. 🙂David Buck
07/11/2022, 3:43 PMsknowlton
07/11/2022, 3:44 PMsknowlton
07/11/2022, 3:44 PMsknowlton
07/11/2022, 3:44 PMMatt Jones
07/11/2022, 3:44 PMsknowlton
07/11/2022, 3:45 PMNick
07/11/2022, 3:51 PMbhartsfield
07/12/2022, 1:16 PMNick
07/12/2022, 4:37 PMBIT
data type in SQL Server. If using <cfqueryparam>
lightens the DB load `CAST`'ing an integer 0/1 to a BIT
, then as a general rule it might be better to use <cfqueryparam>
even on a value that would never change. But it definitely doesn't makes sense because (a) SQL Server would have you write queries with 1/0 so there doesn't seem to be a more efficient way of scripting a direct query to match the BIT
data type, and (b) like you said, there's the cost of the larger query plan for the minimum (if existent) effort to convert integer 1/0 to bit by the DB.David Buck
07/12/2022, 11:47 PMBIT
is an integer data type, so a literal 0 or 1 is probably about the best you can do for avoiding type conversion. Using a boolean value would presumably add a conversion rather than avoiding one.Nick
07/12/2022, 11:54 PM