Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MS SQL SERVER 2005È«ÎÄË÷Òý


MS SQL SERVER 2005È«ÎÄË÷Òýѧϰ±Ê¼ÇÒ»
      ÏÈÁ˽âÒ»ÏÂÈ«ÎÄË÷ÒýÊÇÈçºÎ´´½¨ºÍʹÓõÄ
      ´´½¨È«ÎÄË÷Òý:
      ÔÚMS SQL SERVER 2005Àï,È«ÎÄË÷ÒýÊÇÒ»¸öµ¥¶ÀµÄ·þÎñÏî,ĬÈÏÊÇÆô¶¯µÄ,µ«ÊÇûÓÐÔÊÐíÊý¾Ý¿âÆôÓÃÈ«ÎÄË÷Òý,Èç¹ûÒªÔÚij¸öÊý¾Ý¿âÖд´½¨È«ÎÄË÷Òý,ÏÈÒªÆôÓÃÊý¾Ý¿âµÄÈ«ÎÄË÷Òý.
      ÆôÓ÷½·¨:
      1.Êý¾Ý¿â->ÊôÐÔ->³£¹æ->ÆôÓÃÈ«ÎÄË÷Òý   --execute sp_fulltext_database 'enable'
      2.ÔÚ²éѯÖÐÖ´ÐÐ:,Èç¹ûûÓÐÆôÓþÍÖ´ÐÐÒÔÉÏÆô¶¯Óï¾ä£¬È»ºó´´½¨Ë÷ÒýĿ¼. 
       --execute sp_fulltext_catalog 'ft_titles', 'create'       
      ÆôÓÃÁËË÷ÒýÁË,¾Í¿ÉÒÔ´´½¨Ë÷ÒýĿ¼ÁË
      ÔÚ²éѯÖÐÖ´ÐÐÒÔÏÂÓï¾ä:
      CREATE FULLTEXT CATALOG Ë÷ÒýĿ¼Ãû
      Ö´ÐÐÒÔºó,¾Í»áÔÚSQL SERVERµÄ°²×°Ä¿Â¼Àï¿´µ½Ò»¸öͬÃûµÄĿ¼ÃûÁË,·¾¶ÎªMSSQL.1/MSSQL/FTDATA/Ë÷ÒýĿ¼Ãû
      
      Ã¿¸ö±íÖ»¿ÉÒÔÓÐÒ»¸öÈ«ÎÄË÷Òý,´æ·ÅÔÚÖ¸¶¨µÄË÷ÒýĿ¼Àï,¿ÉÒÔͨ¹ýÏòµ¼´´½¨,Ò²¿ÉÒÔͨ¹ýSQL´´½¨
      »ù±¾Óï·¨:
      CREATE FULLTEXT INDEX ON tablename
      £¨Ë÷ÒýÁÐ1,Ë÷ÒýÁÐ2...£©
      KEY INDEX indexname ON Ë÷ÒýĿ¼Ãû
      indexnameÊÇÖ¸ÒÑ´æÔڵĻùÓÚÖ¸¶¨±íµÄΨһË÷ÒýÃû.¶ø²»ÊÇΨһË÷ÒýÁÐÃû.Èç¹ûË÷Òý²»´æÔÚ,ÐèÒªÏÈ´´½¨Î¨Ò»Ë÷Òý.
      
      Ê¹ÓÃÈ«ÎÄË÷Òý:
      Ö÷ҪʹÓÃCONTAINS,FREETEXT½øÐвéѯ
      ¼ÙÉèÒÑÓÐÒ»¸ö±ímusic,ÒÑΪ×Ö¶Îmemo´´½¨È«ÎÄË÷Òý,ÄÇôҪ²éѯº¬ÓÐÖܽÜÂ×»òÕßjayµÄËùÓмǼµÄÓï¾äΪ:
      SELECT * from mu


Ïà¹ØÎĵµ£º

¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨

1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
      Àý:      Select * from tableName
                Exec('select * from tableName')
        & ......

SQL·ÖÒ³ ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³

Óï¾äÐÎʽ£º¡¡ SELECTTOP10*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOP20id
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fromTestTable
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ORDERBYid)AST))
ORDERBYID
SELECTTOPÒ³´óС*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOPÒ³´óС*Ò³Êýid
¡¡¡¡¡ ......

SQL²éѯÓï¾äʹÓÃ

Ò»¡¢¼òµ¥²éѯ
¡¡¡¡ ¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣
ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable WHERE name='ÕÅÈý'
(Ò»)Ñ¡ÔñÁбí
¡ ......

sql²éÕÒij¸ö×Ö·û´®µÚN´Î³öÏÖµÄλÖõĺ¯Êý(תÌû)

if exists(select 1 from sysobjects where name='char_index')
drop function char_index
create function char_index(@string varchar(8000),@char varchar(10),@index smallint)
--@string:´ý²éÕÒ×Ö·û´®£¬@index:²éÕÒλÖÃ
returns smallint
as
begin
  declare
  @i tinyint,--µ±Ç°ÕÒµ½µÚ@i¸ö
  ......

SQLÓï¾ä´´½¨£¨Êý¾Ý¿â|Êý¾Ý±í|Ë÷Òý£©

CREATE Table <±íÃû>
   £¨[<ÁÐÃû1>] ÀàÐÍ (³¤¶È) [ȱʡֵ][Áм¶Ô¼Êø]
     [£¬<ÁÐÃû2> Êý¾ÝÀàÐÍ[ȱʡֵ][Áм¶Ô¼Êø]]….
     [£¬UNIQUE£¨ÁÐÃû[£¬ÁÐÃû]….£©]
     [£¬PRIMARY KEY£¨ÁÐÃû[£¬ÁÐÃû]…£©]
&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ