April 28, 2008 at 10:49 am
when i am trying to create a function getting "it is an incompatible object type " error
please Help
Create Function dbo.Sp_SplitData
(@Text Text )
Returns @TempImport TABLE(Idx BIGINT IDENTITY(1,1), SplitedLine VARCHAR(8000), Size INT)
AS
Begin
DECLARE @StrLine VARCHAR(8000)
DECLARE @Size BIGINT
DECLARE @Start BIGINT
DECLARE @Separator VARCHAR(1)
--DECLARE @TempImport TABLE(Idx BIGINT IDENTITY(1,1), SplitedLine VARCHAR(8000), Size INT)
SET @Size = 1
SET @Start = 1
SET @Separator = '<'
WHILE (@Start < DATALENGTH(@Text) + 1) BEGIN
SET @Size = CHARINDEX(@Separator, SUBSTRING(@Text, @Start, DATALENGTH(@Text)), 1)
IF @Size = 0 SET @Size = DATALENGTH(@Text) - @Start + 1
SET @StrLine = SUBSTRING(SUBSTRING(@Text, @Start, DATALENGTH(@Text)), 1, @Size)
SET @StrLine = REPLACE(@StrLine,@Separator,'')
INSERT INTO @TempImport(SplitedLine, Size) VALUES('<'+@StrLine, LEN(@StrLine))
SET @Start = @Start + @Size
END
Return
end
April 28, 2008 at 3:42 pm
I copied your script and paste it on both SQL 2000/2005. I ran it without any issue.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply