首页 > 解决方案 > SQL Server 子字符串(子字符串())

问题描述

使用两次 substing() 给我一个错误。有没有办法得到相同的结果?

select [Identifiant] as [ID payment],
       [Etat de la dépense] as [Status payment],
       [Code bénéficiaire] as [Recipient code of payment],
       substring(substring([Information projet], 83, 100) as [sting], 1, PATINDEX('%Code Branche%', [string])-1) as [Recipient of payment]
 into [DB].[dbo].[Check_Result]
 from [DB].[dbo].Expenses_SAP$

标签: sql-server

解决方案


您不能为内部子字符串设置别名。目前尚不清楚您将尝试通过这样做来实现什么,所以我不能真正建议正确的方法来做任何事情。

拿出来as [sting],至少你应该有有效的语法:

substring(substring([Information projet], 83, 100), 1, PATINDEX('%Code Branche%', [string])-1) as [Recipient of payment]

推荐阅读