如何爲以下代碼創建存儲過程。如何製作存儲過程
use Test
DECLARE @Str VARCHAR(120)
SET @Str = 'company name'
DECLARE @End INT
DECLARE @Split INT
SET @Split = 40
declare @SomeTable table
(
Content varchar(120)
)
WHILE (LEN(@Str) > 0)
BEGIN
IF (LEN(@Str) > @Split)
BEGIN
SET @End = LEN(LEFT(@Str, @Split)) - CHARINDEX(' ', REVERSE(LEFT(@Str, @Split)))
INSERT INTO @SomeTable VALUES (RTRIM(LTRIM(LEFT(LEFT(@Str, @Split), @End))))
SET @Str = SUBSTRING(@Str, @End + 1, LEN(@Str))
END
ELSE
BEGIN
INSERT INTO @SomeTable VALUES (RTRIM(LTRIM(@Str)))
SET @Str = ''
END
END
SELECT *
FROM @SomeTable
你有*嘗試*增加你的代碼存儲過程? – LittleBobbyTables
一些非常基本的搜索會給你很多教程和例子。對不起,但由於缺乏努力而失望 – freefaller