我对 SQL Server 还很陌生。我想用同一个表中另一列的数据替换空列。
Declare @ref As mgr.gl_jlhdr.ref_no
Declare @P_no As mgr.gl_jlhdr.jlno
IF ref = Null
Then ref = P_no
end if
请帮忙。
我收到错误
The type name 'mgr.gl_jlhdr.ref_no' contains more than the maximum number of prefixes. The maximum is 1.
我想要的是用其他列数据替换空值列。
示例
如果reference_no
为空,我希望它使用Product_no
数据。
最佳答案
在查询中,您可以使用coalesce()
来执行此操作:
select coalesce(reference_no, product_no)
from mgr.gl_jlhdr;
关于SQL Server : IF null Replace with other column data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31016419/