我根据varchar
分隔spaces
(我知道空格的数量)
我使用stored procedure (Recursive)
来执行此操作
Alter procedure [dbo].[1234]
@name varchar(100),
@count int
AS
BEGIN
if @count=1
begin
set @name=SUBSTRING(@name,CHARINDEX(' ',@name,1)+1,LEN(@name))
select @name
end
if @count>1
begin
select SUBSTRING(@name,1,CHARINDEX(' ',@name,1)-1)
set @count=@count-1
set @name=SUBSTRING(@name,CHARINDEX(' ',@name,1)+1,LEN(@name))
exec [dbo].[1234] @name,@count
end
END
我在
上执行以下SPexec [dbo].[1234] 'a b c d e f g h',8
我的结果是
但我希望我的结果为
答案 0 :(得分:3)
Alter procedure [dbo].[1234]
@name varchar(100)
as
Select @name='Select' + ''''+Replace(@name,' ',''',''')+''''
EXEC( @name)
GO
[1234] 'A b c d e f'