如何在 SQL Server 中创建忽略 NULL 值的计算几何列

问题描述

我有一个站点”表,其中包含 SSMS 2017 中的纬度和经度列。我想添加一个基于纬度和经度值的地理数据类型的计算列。我用过这个命令:

class First extends StatelessWidget {
  final AtomFeed Feed;

  First(this.Feed);

 @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('RSS'),),body: ListView.builder(
          itemCount: this.Feed.items.length,itemBuilder: (BuildContext ctxt,int index) {
            final item = this.Feed.items[index];
            return ListTile(
              title: Text(item.title),subtitle: Text('Published at ' +
                  DateFormat.yMd().format(DateTime.parse(item.published))),contentPadding: EdgeInsets.all(16.0),onTap: () async {
                Navigator.push(
                    context,MaterialPageRoute(
                        builder: (context) => WebViewContainer(
                            item.id.replaceFirst('http','https'))));
              },);
          }),);
  }
}

此命令成功完成,但是当我尝试从表中选择 * 时,它返回屏幕截图 failed select command error message显示错误。我怀疑这是因为某些站点没有 Lat/Long 数据(是 NULL 值)。有没有办法解决这个问题?

解决方法

先尝试过滤值。像这样:

ALTER TABLE Sites 
 ADD Geo2 AS IIF(Latitude  IS NOT NULL AND Longitude IS NOT NULL,[geography]::Point(Longitude,Latitude,4326),NULL)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...