如何在 SQL 服务器的列中获取合并错误
How to get consolidated errors in column in SQL Server
我有一个要求需要找出包含错误报告的所有列的合并错误报告。在 SQL 服务器中是否有任何功能或方法可以做到这一点?
我尝试使用 CASE
语句,但它只给出一列的错误报告。
应用过滤器或程序后我需要这样的结果
您可以使用 CASE
:
select
row,
case when length(name) > 10
then 'Name max=10 Present=' + length(name) + '; '
else '' end +
case when length(place) > 10
then 'Place max=10 Present=' + length(place) + '; '
else '' end +
case when length(address) > 10
then 'Address max=10 Present=' + length(address) + '; '
else '' end as error
from t
我有一个要求需要找出包含错误报告的所有列的合并错误报告。在 SQL 服务器中是否有任何功能或方法可以做到这一点?
我尝试使用 CASE
语句,但它只给出一列的错误报告。
应用过滤器或程序后我需要这样的结果
您可以使用 CASE
:
select
row,
case when length(name) > 10
then 'Name max=10 Present=' + length(name) + '; '
else '' end +
case when length(place) > 10
then 'Place max=10 Present=' + length(place) + '; '
else '' end +
case when length(address) > 10
then 'Address max=10 Present=' + length(address) + '; '
else '' end as error
from t