I need some help splitting an address string at 30 Char or the closest space before 30 . I have found the below which works but get errors if i remove the "where DeliveryAddress = 2651"
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Any help Greatly appreciated in finding a solution
declare @strs nvarchar(max)
set @strs = (select distinct deliveryaddresses.address from DeliveryAddresses where DeliveryAddress = 2651)
set @strs = reverse(@strs)
select reverse(@strs) String,
reverse(right(@strs,len(@strs) - charindex(' ',@strs,30))) Description1,
ltrim(reverse(left(@strs,charindex(' ',@strs,30)))) Description2