English 中文(简体)
NullDisplayText in signup vs ISNUL(field, 0) in Q?
原标题:NullDisplayText in markup vs ISNULL(field, 0) in SQL?

更好的做法是:

  • BoundField.NullDisplayText isn t set. NULL-case is f或eseen in SQL query, i.e. SELECT ISNULL(amount, 0) FROM table

  • BoundField.NullDisplayText is set, e.g. "0.00 %". NULL-case isn t f或eseen in SQL query, i.e. SELECT amount FROM table

你认为什么?

最佳回答

你们能够做得最好吗?

  • ISNULL only serves this single case
  • Formatting/logic should be in the UI
  • Other clients using "amount" may expect NULL so you now have an inconsistent "contract"
  • 0 means zero, NULL means unknown/nothing: 2 different states
问题回答

很显然,因为你与国际空间法学会进行了过滤。

我想说,第二种选择更好。 通常最好是在中层或列报层而不是数据库中格式产出。 因此,我要将数据级代码上下级的倒数归来,并决定是否在数据库中显示而不是作出选择。

通过将“零”改为“零”,你对所有使用“无”一词的系统表示,“无”是指有意进入零的用户”。 如果情况确实如此,则处以罚款,使用Coalesce,而不是IsNull,并将无效改为零。 然而,如果甚至最有可能重新利用询问,而且没有价值可能受到与零的输入不同的对待,那么我就将不再进入中间层,让它决定如何这样做。

差异是0.00意味着外地具有价值,而全国人民力量则意味着相反。 因此,从数据精度的角度来看,前者是正确的。





相关问题
How to write this T-SQL WHERE condition?

I ve got two tables: TableA Col1 Col2 TableB Col3 Col4 I want to join them together: SELECT * from TableA join TableB ON (...) Now, in place of ... I need to write an expression ...

Customer and Order Sql Statement

TSQL query to select all records from Customer that has an Order and also select all records from customer that does not have an Order. The table Customer contains a primary key of CustomerID. The ...

Recommended way of querying multiple Versioned tables

Have a win 2003 box with MSSQL 2005 running on it. There is a database which is populated every morning with new/modified SalesOrder made the previous day. The database has several tables: SalesOrder, ...

update duplicate record

I have a table with the following fields Id Name IsPublic i need to write a sql query that updates IsPublic to false where name has a duplicate. Only one of the duplicates should have IsPublic = ...

Define variable to use with IN operator (T-SQL)

I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"? ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签