我有以下 SQL 代码:
select @colNames = coalesce(@colNames+',','')+''''+ RptLOB1 +''''
from CM.Correlation
group by RptLOB1
print @colNames
insert into AnalyticsV2.dbo.ResultCSV values('', @colNames)
打印@colNames
内容如下:
'Accident and Health','AE','Avemco Aviation','Bail','Commercial','Contingency','Contract','Court','Credit','DFP','DIC','Disability','Energy and Marine','EPLI','Excess Casualty','Exited Lines','Fidelis Marine','Fidelity','Group Life','HC Houston Aviation','HCC Indemnity Guaranty','HCCG International','HCCG US','HCCMIS','HCRM','Indemco','Large Commercial','Liability','Medical Stop Loss','MPL','Niche and Other Specialty','Occupational Accident','Other Aviation','Other International','Other Surety','Other US PC','PI','Primary Casualty','Property DF','Property Treaty','Public Risk','Surety','Technical Property','UK Credit','USSIC Aviation'
45 个不同的 RptLOB。
当我执行它给我以下错误信息:
列名或提供的值的数量与表定义不匹配。
我的表有 46 列,插入语句中的空白列应该对此进行调整。为什么这会给我一个错误?
任何帮助将不胜感激!