哪里不是数据类型 sql
where not dataype sql
我正在尝试过滤一些数据 - 我有一个看起来主要是 smallint/int 的列。无论如何,我可以 运行 一个 where 语句来说明 where not int 或 where not small int 吗??
Microsoft SQL 服务器管理器。
如果您想要一个可以告诉您列是否包含无法转换为 int
或 smallint
的信息的 where 子句,您可以使用 try_cast
:
SELECT *
FROM <TableName>
WHERE TRY_CAST(<ColumnName> AS Int) IS NULL
您可以将 int
更改为 smallint
以获得无法转换为 smallint
但可以转换为 int
的值。
不要忘记将 <TableName>
和 <ColumnName>
替换为相关 table 和列的名称。
如果 <ColumnName>
中的值为 null 或无法转换为 int
(并且由于所有smallint
值也可以转换为int
,也不能转换为smallint
).
我正在尝试过滤一些数据 - 我有一个看起来主要是 smallint/int 的列。无论如何,我可以 运行 一个 where 语句来说明 where not int 或 where not small int 吗??
Microsoft SQL 服务器管理器。
如果您想要一个可以告诉您列是否包含无法转换为 int
或 smallint
的信息的 where 子句,您可以使用 try_cast
:
SELECT *
FROM <TableName>
WHERE TRY_CAST(<ColumnName> AS Int) IS NULL
您可以将 int
更改为 smallint
以获得无法转换为 smallint
但可以转换为 int
的值。
不要忘记将 <TableName>
和 <ColumnName>
替换为相关 table 和列的名称。
如果 <ColumnName>
中的值为 null 或无法转换为 int
(并且由于所有smallint
值也可以转换为int
,也不能转换为smallint
).