Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 cannot call on method nvarchar

Author  Topic 

spshindagi
Starting Member

11 Posts

Posted - 2008-01-24 : 02:39:20
the following is fuction to split string array
ALTER FUNCTION monthfunc
(@list nvarchar(MAX),
@delimiter nchar(1) = N',')
RETURNS @tbl TABLE (listpos int IDENTITY(1, 1) NOT NULL,
str varchar(4000) NOT NULL,
nstr nvarchar(2000) NOT NULL,
mth nvarchar(2000) NOT NULL,
suffix nvarchar(2000) NOT NULL) AS

BEGIN
DECLARE @endpos int,
@startpos int,
@textpos int,
@chunklen smallint,
@tmpstr nvarchar(4000),
@leftover nvarchar(4000),
@mth1 nvarchar(4000),
@suffix1 nvarchar(4000),
@tmpval nvarchar(4000)

SET @textpos = 1
SET @leftover = ''
WHILE @textpos <= datalength(@list) / 2
BEGIN
SET @chunklen = 4000 - datalength(@leftover) / 2
SET @tmpstr = @leftover + substring(@list, @textpos, @chunklen)
SET @textpos = @textpos + @chunklen

SET @startpos = 0
SET @endpos = charindex(@delimiter COLLATE Slovenian_BIN2, @tmpstr)

WHILE @endpos > 0
BEGIN
SET @tmpval = ltrim(rtrim(substring(@tmpstr, @startpos + 1,
@endpos - @startpos - 1)))
INSERT @tbl (str, nstr,mth,suffix) VALUES(@tmpval, @tmpval,@tmpval,@tmpval)
SET @startpos = @endpos
SET @endpos = charindex(@delimiter COLLATE Slovenian_BIN2,
@tmpstr, @startpos + 1)
END

SET @leftover = right(@tmpstr, datalength(@tmpstr) / 2 - @startpos)
SET @mth1=@leftover.Substring(0, 3).ToString();
SET @suffix1=@leftover.Remove(0, 3).ToString();
END

INSERT @tbl( str,nstr,mth,suffix)
VALUES ( ltrim(rtrim(@leftover)),ltrim(rtrim(@leftover)),@mth1,@suffix1)
RETURN
END
how to resolve this error.
Help is appreciated


love all

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-24 : 13:05:12
I believe you are combining technologies:

this:
SET @mth1=@leftover.Substring(0, 3).ToString();

should be:
set @mth1=Substring(@leftover, 1, 3);

similar issue with:
@suffix1=@leftover.Remove(0, 3).ToString();


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -