含有 ‘String’標籤(tag)的文章們

TSQL: Parsing delimited string into table

From
http://rbgupta.blogspot.com/2007/10/tsql-parsing-delimited-string-into.html
ALTER FUNCTION dbo.udf_ItemParse (@Input VARCHAR(4000), @Delimeter char(1)=’|’)
RETURNS @ItemList TABLE (Item VARCHAR(200) ,RowID int)
AS
BEGIN
DECLARE @Item varchar(200)
DECLARE @StartPos int, @Length int
DECLARE @Pos int
SET @Pos = 0
WHILE LEN(@Input) > 0
BEGIN
SET @StartPos = CHARINDEX(@Delimeter, @Input)
IF @StartPos < 0 SET @StartPos = 0
SET @Length = LEN(@Input) – @StartPos – 1
IF (@StartPos > 0)
BEGIN
SET @Pos = @Pos + 1
SET @Item = [...]

Continue reading »

利用FileSteam 讀檔 , 回傳字串資料

//File Content Transfer to String
private String LoadDecodedFile(String file)
{
String DecodedString = “”;
FileStream fs = new FileStream(file, FileMode.Open);
StreamReader r = new StreamReader(fs);
// Position the file pointer at the beginning of the file.
r.BaseStream.Seek(0, SeekOrigin.Begin);
// Read the entire file into a string and decode each chunk.
while (r.Peek() > -1)
DecodedString += Server.HtmlDecode(r.ReadLine());
r.Close();
return DecodedString;
}

Continue reading »