0
USE [Curatas_Live]
GO
/****** Object: UserDefinedFunction [dbo].[BreakStringIntoRows] Script Date: 22-02-2017 12:52:32 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[BreakStringIntoRows] (@CommadelimitedString varchar(1000))
RETURNS [@Result VARCHAR(100)]
AS
BEGIN
declare @result VARCHAR(100)
DECLARE @IntLocation INT
DECLARE @ResultCode VARCHAR(100)
SET @Result = ''
WHILE (CHARINDEX(',', @CommadelimitedString, 0) > 0)
BEGIN
SET @IntLocation = CHARINDEX(',', @CommadelimitedString, 0)
SELECT @ResultCode = RTRIM(LTRIM(SUBSTRING(@CommadelimitedString, 0, @IntLocation)))
SELECT @Result [email protected] + ITMSGRPNAME FROM OITB
WHERE [email protected]
SET @CommadelimitedString = STUFF(@CommadelimitedString, 1, @IntLocation, '')
END
SELECT @ResultCode = RTRIM(LTRIM(@CommadelimitedString))--LTRIM and RTRIM to ensure blank spaces are removed
SELECT @Result [email protected] + ITMSGRPNAME FROM OITB
WHERE [email protected]
RETURN @Result
END
請解釋什麼錯誤 – YdB
你真的希望一個答案?只是*函數執行錯誤*和一些代碼?請閱讀[如何問一個好的SQL問題](http://meta.stackoverflow.com/questions/271055/tips-for-asking-a-good-structured-query-language-sql-question/271056)和[如何創建一個MCVE](http://stackoverflow.com/help/mcve)並陳述您的實際錯誤信息! – Shnugo
我得到以下錯誤消息2715,級別16,狀態3,過程BreakStringIntoRows,行26 列,參數或變量#0:無法找到數據類型@Result VARCHAR(100)。 參數或變量「'具有無效的數據類型。 –