马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Merge将一定数量的MyISAM表联合而成一个整体,在超大规模数据存储时很有用
/******************************************************************************
*Author:iret
*Desc:T-SQLExtractor
*ExtractthecommentsandblanksandtabsfromtheSQLstatement
*为了对照两个存储历程,大概SQL语句是不是分歧,抽暇写了一个能够删除T-SQL语句中的正文和空格的剧本,挺精巧的模样。
*CreatedDate:2004/10/21
******************************************************************************/
DECLARE@scriptVARCHAR(8000),@extractedScriptVARCHAR(4000)
SET@script=
/*从体系表猎取存储历程的剧本*/
SELECT@script=@script+[text]
FROMsyscomments,sysobjects
WHERE
syscomments.[id]=sysobjects.[id]ANDsysobjects.[name]LIKE%campa_AppSegment
/*标记符*/
DECLARE@InLineCommentedBIT,@InSectionCommentedBIT,@InStringBIT,@positionINT
/*以后字符*/
DECLARE@curCharINT
/*前一个字符*/
DECLARE@preCharINT
SET@InLineCommented=0
SET@InSectionCommented=0
SET@InString=0
SET@extractedScript=
SET@position=1
SET@preChar=null
WHILE@position<=DATALENGTH(@script)
BEGIN
--猎取以后字符
SET@curChar=ASCII(SUBSTRING(@script,@position,1))
IF@preChar=ASCII(/)AND@curChar=ASCII(*)AND@InLineCommented=0AND@InString=0
BEGIN
--SETthesigninsectioncomment
SET@InSectionCommented=1
--popthe/char
SET@extractedScript=substring(@extractedScript,1,len(@extractedScript)-1)
SET@preChar=@curChar
SET@position=@position+1
CONTINUE
END
IF@preChar=ASCII(*)AND@curChar=ASCII(/)AND@InLineCommented=0AND@InString=0
BEGIN
SET@InSectionCommented=0
SET@preChar=@curChar
SET@position=@position+1
CONTINUE
END
IF@preChar=ASCII(-)AND@curChar=ASCII(-)AND@InSectionCommented=0AND@InString=0
BEGIN
SET@InLineCommented=1
--popthe/char
SET@extractedScript=substring(@extractedScript,1,len(@extractedScript)-1)
SET@preChar=@curChar
SET@position=@position+1
CONTINUE
END
IF@curChar=ASCII()AND@InString=0AND@InSectionCommented=0AND@InLineCommented=0
BEGIN
SET@InString=1
END
IF@inString=1AND@curChar=ASCII()
BEGIN
IFASCII(SUBSTRING(@script,@position+1,1))=ASCII()
BEGIN
SET@extractedScript=@extractedScript+
SET@position=@position+1
END
ELSE
BEGIN
SET@InString=0
END
END
IF@InSectionCommented=1
BEGIN
SET@preChar=@curChar
SET@position=@position+1
CONTINUE
END
IF@InLineCommented=1
BEGIN
--ifmeetstheendofthelinesettheInLineCommentedtofalse
IF@curChar=10AND@preChar=13
BEGIN
SET@InLineCommented=0
END
SET@preChar=@curChar
SET@position=@position+1
CONTINUE
END
IF@curChar=ASCII()OR@curChar=10OR@curChar=13OR@curChar=ASCII()OR@curChar=32
BEGIN
SET@preChar=@curChar
SET@position=@position+1
CONTINUE
END
SET@extractedScript=@extractedScript+CHAR(@curChar)
SET@preChar=@curChar
SET@position=@position+1
END
--printtheresultscript
SELECT@extractedScript
如果某个数据列里包含许多重复的值,就算为它建立了索引也不会有很好的效果。比如说,如果某个数据列里包含的净是些诸如“0/1”或“Y/N”等值,就没有必要为它创建一个索引。 |