sqlserverÖÐʹÓÃÕýÔò±í´ïʽ2
ÕâÁ½ÌìÓиöÐèÇó£¬ÐèÒªÔÚÊý¾Ý¿âÖÐÅжÏ×Ö·û´®µÄ¸ñʽ£¬ÓÚÊÇ´ÓÍøÉÏËѼ¯ÁËһЩ×ÊÁÏ£¬ÕûÀíÁËһϡ£
ÏÂÃæÕâ¸öÊÇÒ»¸ö×Ô¶¨Ò庯Êý£¬Óû§¿ÉÒÔµ÷ÓÃÕâ¸öº¯ÊýÅжÏÖ¸¶¨µÄ×Ö·û´®ÊÇ·ñ·ûºÏÕýÔò±í´ïʽµÄ¹æÔò.
CREATE FUNCTION dbo.find_regular_expression
(
@source varchar(5000), --ÐèҪƥÅäµÄÔ´×Ö·û´®
@regexp varchar(1000), --ÕýÔò±í´ïʽ
@ignorecase bit = 0 --ÊÇ·ñÇø·Ö´óСд£¬Ä¬ÈÏΪfalse
)
RETURNS bit --·µ»Ø½á¹û0-false£¬1-true
AS
BEGIN
--0£¨³É¹¦£©»ò·ÇÁãÊý×Ö£¨Ê§°Ü£©£¬ÊÇÓÉ OLE ×Ô¶¯»¯¶ÔÏó·µ»ØµÄ HRESULT µÄÕûÊýÖµ¡£
DECLARE @hr integer
--ÓÃÓÚ±£´æ·µ»ØµÄ¶ÔÏóÁîÅÆ£¬ÒÔ±ãÖ®ºó¶Ô¸Ã¶ÔÏó½øÐвÙ×÷
DECLARE @objRegExp integer DECLARE @objMatches integer
--±£´æ½á¹û
DECLARE @results bit
/*
´´½¨ OLE ¶ÔÏóʵÀý,Ö»ÓÐ sysadmin ¹Ì¶¨·þÎñÆ÷½ÇÉ«µÄ³ÉÔ±²ÅÄÜÖ´ÐÐ sp_OACreate,²¢È·¶¨»úÆ÷ÖÐÓÐVBScript.RegExpÀà¿â
*/
EXEC @hr = sp_OACreate 'VBScript.RegExp', @objRegExp OUTPUT
IF @hr <> 0 BEGIN
SET @results = 0
RETURN @results
END
/*
ÒÔÏÂÈý¸ö·Ö±ðÊÇÉèÖÃн¨¶ÔÏóµÄÈý¸öÊôÐÔ¡£ÏÂÃæÊÇ'VBScript.RegExp'Öг£ÓõÄÊôÐÔ¾ÙÀý£º
Dim regEx,Match,Matches '½¨Á¢±äÁ¿¡£
Set regEx = New RegExp '½¨Á¢Ò»°ã±í´ïʽ¡£
regEx.Pattern= patrn 'ÉèÖÃģʽ¡£
regEx.IgnoreCase = True 'ÉèÖÃÊÇ·ñÇø·Ö´óСд¡£
regEx.Global=True 'ÉèÖÃÈ«¾Ö¿ÉÓÃÐÔ¡£
set Matches=regEx.Execute(string)
Ïà¹ØÎĵµ£º
SQLSERVER ´óÊý¾ÝÁ¿²åÈëÃüÁ
BULK INSERTÊÇSQLSERVERÖÐÌṩµÄÒ»Ìõ´óÊý¾ÝÁ¿µ¼ÈëµÄÃüÁËüÔËÓÃDTS(SSIS)µ¼ÈëÔÀí£¬¿ÉÒÔ´Ó±¾µØ»òÔ¶³Ì·þÎñÆ÷ÉÏÅúÁ¿µ¼ÈëÊý¾Ý¿â»òÎļþÊý¾Ý¡£ÅúÁ¿²åÈëÊÇÒ»¸ö¶ÀÁ¢µÄ²Ù×÷£¬ÓŵãÊÇЧÂʷdz£¸ß¡£È±µãÊdzöÏÖÎÊÌâºó²»¿ÉÒԻعö¡£
¡¡¡¡BULK INSERTÊÇÓÃÀ´½«ÍⲿÎļþÒÔÒ»ÖÖÌض¨µÄ¸ñʽ¼ÓÔ ......
SQLserver×Ö·û´®·Ö¸îº¯Êý
Ò»¡¢°´Ö¸¶¨·ûºÅ·Ö¸î×Ö·û´®£¬·µ»Ø·Ö¸îºóµÄÔªËظöÊý£¬·½·¨ºÜ¼òµ¥£¬¾ÍÊÇ¿´×Ö·û´®ÖдæÔÚ¶àÉÙ¸ö·Ö¸ô·ûºÅ£¬È»ºóÔÙ¼ÓÒ»£¬¾ÍÊÇÒªÇóµÄ½á¹û¡£
CREATE function Get_StrArrayLength
(
@str varchar(1024), --Òª·Ö¸îµÄ×Ö·û´®
@split varchar(10) --·Ö¸ô·ûº ......
sqlserver×Ö·û´®²ð·Ö(split)·½·¨»ã×Ü
--·½·¨0£º¶¯Ì¬SQL·¨
declare @s varchar(100),@sql varchar(1000)
set @s='1,2,3,4,5,6,7,8,9,10'
set @sql='select col='''+ replace(@s,',',''' union all select ''')+''''
PRINT @sql
exec (@sql)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ ......
SQL ServerÊý¾Ý¿âÉè¼Æ±íºÍ×Ö¶Î
2009/02/18 12:29
1. Ôʼµ¥¾ÝÓëʵÌåÖ®¼äµÄ¹Øϵ
¡¡¡¡¿ÉÒÔÊÇÒ»¶ÔÒ»¡¢Ò»¶Ô¶à¡¢¶à¶Ô¶àµÄ¹Øϵ¡£ÔÚÒ»°ãÇé¿öÏ£¬ËüÃÇÊÇÒ»¶ÔÒ»µÄ¹Øϵ£º¼´Ò»ÕÅÔʼµ¥¾Ý¶ÔÓ¦ÇÒÖ»¶ÔÓ¦Ò»¸öʵÌå¡£ÔÚÌØÊâÇé¿öÏ£¬ËüÃÇ¿ÉÄÜÊÇÒ»¶Ô¶à»ò¶à¶ÔÒ»µÄ¹Øϵ£¬¼´Ò»ÕÅÔʼµ¥Ö¤¶ÔÓ¦¶à¸öʵÌ壬»ò¶àÕÅÔʼµ¥Ö¤¶ÔÓ¦Ò»¸öʵÌå¡£ÕâÀïµÄʵÌå¿ ......