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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Extract part of string from a text filed

Author  Topic 

yipchunyu
Yak Posting Veteran

80 Posts

Posted - 2005-09-01 : 03:22:57
One table has a text field which is used html codes.
I want to extract part of the string and so I create a function listed in the followings. However, it seems that the function can't display Chinese characters correctly. What should I do?


CREATE FUNCTION dbo.ExtractAptLoc
( @Note text )
RETURNS nvarchar(200)
AS
BEGIN

Declare @StartPos int
Declare @EndPos int
DECLARE @output nvarchar(200)

select @StartPos = PATINDEX('%<loc>%', @Note) + 11
select @EndPos = PATINDEX('%</loc>%', @Note) - @StartPos


IF PATINDEX('%<loc>%', @Note) = 0 or PATINDEX('%</loc>%', @Note) = 0
BEGIN
SET @output = Null
END

ELSE

BEGIN
SET @output =Substring(@Note, @StartPos , @EndPos )
END
RETURN @output
END

Kristen
Test

22859 Posts

Posted - 2005-09-01 : 03:49:04
Duplicate of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=54658

Kristen
Go to Top of Page
   

- Advertisement -