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

ÈçºÎÔÚSQLÖÐÆôÓÃÈ«ÎļìË÷¹¦ÄÜ

ÈçºÎÔÚSQLÖÐÆôÓÃÈ«ÎļìË÷¹¦ÄÜ£¿
¡¡¡¡--------------------------------------------------------------------------------
¡¡¡¡È«ÎÄË÷ÒýµÄÒ»¸öÀý×Ó£¬ÔÚ²éѯ·ÖÎöÆ÷ÖÐʹÓãº
¡¡¡¡use pubs
¡¡¡¡go
¡¡¡¡--´ò¿ªÊý¾Ý¿âÈ«ÎÄË÷ÒýµÄÖ§³Ö
¡¡¡¡execute sp_fulltext_database 'enable'
¡¡¡¡go
¡¡¡¡--½¨Á¢È«ÎÄĿ¼ft_titles
¡¡¡¡execute sp_fulltext_catalog 'ft_titles', 'create'
¡¡¡¡go
¡¡¡¡--Ϊtitles±í½¨Á¢È«ÎÄË÷ÒýÊý¾ÝÔª£¬UPKCL_titleidindÊÇÖ÷¼üËù½¨Á¢µÄΨһË÷Òý£¬¿ÉÓÉsp_help titlesµÃÖª
¡¡¡¡execute sp_fulltext_table 'titles','create', 'ft_titles', 'UPKCL_titleidind'
¡¡¡¡go
¡¡¡¡--ÉèÖÃÈ«ÎÄË÷ÒýÁÐÃû
¡¡¡¡exec sp_fulltext_column 'titles', 'title', 'add'
¡¡¡¡go
¡¡¡¡exec sp_fulltext_column 'titles', 'notes', 'add'
¡¡¡¡go
¡¡¡¡--½¨Á¢È«ÎÄË÷Òý
¡¡¡¡exec sp_fulltext_table 'titles', 'activate'
¡¡¡¡go
¡¡¡¡--Ìî³äÈ«ÎÄË÷ÒýĿ¼
¡¡¡¡exec sp_fulltext_catalog 'ft_titles', 'start_full'
¡¡¡¡go
¡¡¡¡--ʹÓÃcontainsºÍfreetext
¡¡¡¡select title, notes from titles
¡¡¡¡where contains(title, '"computer Cooking"')
¡¡¡¡go
¡¡¡¡select title, notes from titles
¡¡¡¡where freetext(title, 'computer Cooking')
¡¡¡¡go
¡¡¡¡select title, notes from titles
¡¡¡¡where freetext(title, '"computer Cooking"')
¡¡¡¡go
¡¡¡¡select title, notes from titles
¡¡¡¡where contains(title, 'computer')
¡¡¡¡go
¡¡¡¡select title, notes from titles
¡¡¡¡where freetext (*, 'computer')
¡¡¡¡go
------------------------------------------------------------------------------------------------------
ʾÀý
SQL SERVERÊý¾Ý¿âÈ«ÎÄË÷ÒýµÄʾÀý£¬ÒÔpubsÊý¾Ý¿âΪÀý¡£
Ê×ÏÈ£¬½éÉÜÀûÓÃϵͳ´æ´¢¹ý³Ì´´½¨È«ÎÄË÷ÒýµÄ¾ßÌå²½Ö裺
1) Æô¶¯Êý¾Ý¿âµÄÈ«ÎÄ´¦Àí¹¦ÄÜ (sp_fulltext_database)
2) ½¨Á¢È«ÎÄĿ¼ (sp_fulltext_catalog)
3) ÔÚÈ«ÎÄĿ¼ÖÐ×¢²áÐèҪȫÎÄË÷ÒýµÄ±í (sp_fulltext_table)
4) Ö¸³ö±íÖÐÐèҪȫÎÄË÷ÒýµÄÁÐÃû (sp_fulltext_column)
5) Ϊ±í´´½¨È«ÎÄË÷Òý (sp_fulltext_table)
6) Ìî³äÈ«ÎÄĿ¼ (sp_fulltext_catalog)
---------********ʾÀý********-------------
ÒÔ¶ÔpubsÊý¾Ý¿âµÄtitleºÍnotesÁн¨Á¢È«ÎÄË÷Òý£¬Ö®ºóʹÓÃË÷Òý²éѯtitleÁлònotesÁÐÖаüº¬ÓÐdatebase »òcomputer×Ö·û´®µÄͼÊéÃ


Ïà¹ØÎĵµ£º

SQLµ±Ç°ÈÕÆÚ»ñÈ¡¼¼ÇÉ

SQLµ±Ç°ÈÕÆÚ»ñÈ¡¼¼ÇÉ
select   getdate()   //2003-11-07   17:21:08.597    
  select   convert(varchar(10),   getdate(),120)   //2003-11-07  
  select   convert(char(8),getdate(),112)  ......

sql Óï¾ä

select * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHEREselect * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','198 ......

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×¢Èë¹¥»÷

¡¾Ô­ÎĵØÖ·¡¿Tip/Trick: Guard Against SQL Injection Attacks
¡¾Ô­ÎÄ·¢±íÈÕÆÚ¡¿ Saturday, September 30, 2006 9:11 AM
SQL×¢Èë¹¥»÷ÊǷdz£ÁîÈËÌÖÑáµÄ°²È«Â©¶´£¬ÊÇËùÓеÄweb¿ª·¢ÈËÔ±£¬²»¹ÜÊÇʲôƽ̨£¬¼¼Êõ£¬»¹ÊÇÊý¾Ý²ã£¬ÐèҪȷÐÅËûÃÇÀí½âºÍ·ÀÖ¹µÄ¶«Î÷¡£²»ÐÒµÄÊÇ£¬¿ª·¢ÈËÔ±ÍùÍù²»¼¯Öл¨µãʱ¼äÔÚÕâÉÏÃ棬ÒÔÖÁËûÃǵÄÓ¦Ó㬠......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ