![](/img/trans.png)
[英]What is the most efficient way in T-SQL to compare answer strings to answer keys for scoring an exam
[英]What is the most efficient way to code this part of a T-SQL statement?
我正在使用SQL Server 2008和ColdFusion 9.1.2。
我有一個具有整數字段的查詢。 我需要輸入一個整數或null,而不是零。
現在,這就是我所擁有的:
<cfif LOCAL.MyValue eq "">
NULL ,
<cfelse>
<cfqueryparam cfsqltype="cf_sql_numeric" value="#LOCAL.MyValue#">,
</cfif>
什么是最好的方式,或最有效的方式,或最簡潔的方式來編碼:
全部在一行:
<cfqueryparam cfsqltype="cf_sql_numeric" value="#LOCAL.MyValue#" null="#NOT len(LOCAL.MyValue)#">
如果它有長度,則設置null = false。
如果它沒有長度,它將設置null = true,並忽略value
屬性中的內容。
您可能還想在len()內添加trim()(例如,如果用戶可能輸入空格)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.