MSSQLServer2000È«ÎÄË÷ÒýimageÁÐÈ«¹¥ÂÔ
ÈÕÆÚ£º2006-08-02 ¼ö£º
¡¡¡¡½ñÌì¡°°ÙÄê²»Óö¡±µÄÍ£µçÁË£¬¿´ÁËÒ»ÌìÊé¡£ÍíÉϸãÁËÒ»ÏÂÈ«ÎÄË÷Òý£¬¾ö¶¨°ÑÐĵÃÌù³öÀ´£¬ÎÒ¾¡Á¿Ð´µÄÏêϸ£¬´ó¼Ò¹²Í¬Ñ§Ï°£¬»¶ÓÖ¸Õý£¡¡¡¡¡¡¡¡¡1¡¢Æô¶¯ Microsoft Search ·þÎñ¡¡¡¡¡¡¡¡¡¡ ¿ª¼²Ëµ?->SQL³ÌÐò×é·þÎñ¹ÜÀíÆ÷ÏÂÀ¿ðMicrosoft Search ·þÎñÆô¶¯Ëü¡¡¡¡¡¡¡¡2¡¢¡¡¡¡¡¡..Microsoft SQL ServerMSSQLFTDATASQLServerConfigĿ¼Àィһ¸ö·Ç¿Õnoise.chsÎļþ¡¡¡¡¡¡·Ç¿Õnoise.chsÎļþ£¬Ò²ÓÐÈË˵ÊÇ¿ÕµÄnoise.chsÎļþ£¬µ«ÎÒÿ´Î¶¼ÍùÀïд¼¸¸öûÓõÄ×Öĸ¡£¡¡¡¡¡¡¡¡3¡¢½¨Á¢»·¾³¡¡¡¡¡¡¡¡¡¡ ´ò¿ª²éѯ·ÖÎöÆ÷Ö´ÐÐÏÂÁнű¾£º¡¡¡¡--------------------------------------------¡¡¡¡create database test ---´´½¨testÊý¾Ý¿â¡¡¡¡use test¡¡¡¡¡¡¡¡¡¡¡¡ ---Ñ¡ÔñtestÊý¾Ý¿â¡¡¡¡create table¡¡dali (ID int not null primary key,MyImage image,FileType varchar(255),FileNmae varchar(255)) ---´´½¨dali±í¡¡¡¡--dali±íÖÐ Id,MyImage,FileType ÈýÁÐÊDZØÐëµÄ£¬ÒòΪҪ¶ÔimageÁÐË÷ÒýµÄ»°£¬±ØÐëÒªÓÐÒ»¸öÖ÷¼üÁУ¬Ò»¸öimageÁÐ,Ò»¸ö´æ·ÅÎļþÀàÐ͵ÄÁС¡¡¡--ÎÒÃÇÖªµÀÔÚwindowsϵͳÖÐÎļþÀàÐÍÊÇ¿¿À©Õ¹ÃûÀ´Çø·ÖµÄËùÒÔFileTypeÁÐÒ²¾ÍÊÇÓÃÀ´·Å ÎļþµÄÀ©Õ¹Ãû¡¡¡¡--------------------------------------------¡¡¡¡¡¡¡¡sp_fulltext_database 'enable' --ΪȫÎÄË÷ÒýÆôÓÃÊý¾Ý¿â¡¡¡¡sp_fulltext_catalog 'My_FullDir', 'create'¡¡---´´½¨Ò»¸ö½ÐMy_FullDifµÄÈ«ÎÄĿ¼¡¡¡¡¡¡¡¡declare @Key sysname ; select @Key=c.name from syscolumns a,sysconstraints b,sysobjects c where a.id=object_id('a') and a.name='a' and a.id=b.id and b.constid=c.id and c.name like 'PK%'¡¡¡¡exec sp_fulltext_table 'dali','create','My_FullDir',@Key¡¡----ÕâÁ½¾äÊÇΪȫÎÄË÷Òý,¶Ô±í½øÐбê¼Ç¡¡¡¡¡¡¡¡sp_fulltext_column 'dali','MyImage','add',0x0804,'FileType'¡¡---Õâ¾äÊÇÖ¸¶¨MyImageÁÐΪȫÎÄË÷ÒýÁÐ,FileTypeÊÇÀàÐÍÁС¡¡¡------------------------------------------------¡¡¡¡4¡¢ÔÚcÅÌÏ·ÅÒ»¸öÀ©Õ¹ÃûΪdocµÄwordÎļþ,Ò»¸öÀ©Õ¹ÃûΪxlsµÄexcelÎļþ,Ò»¸öÀ©Õ¹ÃûΪhtmµÄÍøÒ³Îļþ,¸öÀ©Õ¹ÃûΪbmpµÄͼƬ¹²4¸ö£¬´ó¼Ò¿É¸ù¾Ýʵ¼ÊÇé¿ö·ÅÈ룡¡¡¡¡¡¡¡¡5¡¢²åÈëÊý¾Ý¡¡¡¡¡¡¡¡¡¡½¨Á¢ÏÂÃæÕâ¸ö´æ´¢¹ý³Ì¡¡¡¡--------------------------------------------------¡¡¡¡CREATE PROCEDURE sp_textcopy¡¡¡¡¡¡@srvname¡¡¡¡varchar (30),¡¡¡¡¡¡@login¡¡¡¡¡¡varchar (30),¡¡¡¡¡¡@password¡¡¡¡varchar (30),¡¡¡¡¡¡@dbname¡¡¡¡¡¡varchar (30),¡¡¡¡¡¡@tbname¡¡¡¡¡¡varchar (30),¡¡¡¡¡¡@colname¡¡¡¡varchar (30),¡¡¡¡¡¡@filename¡¡¡¡varchar (30),¡¡¡¡¡¡@whereclause varchar (40),¡¡¡¡¡¡@direction¡¡char(1)¡¡¡¡AS¡¡¡¡/* ÕâÊÇʹÓÃtextcopy¹¤¾ß½«Îļþ²åÈëµ½Êý¾Ý¿âÖУ¬Èç¹ûÓÐǰ̨¹¤¾ß¿ÉÒÔÓÃǰ̨¿ª·¢¹¤¾ß½«Îļþ²åÈ룬ÕâÀïΪÁËÑÝʾ */¡¡¡¡DECLARE @exec_str varchar (255)¡¡¡¡SELECT @exec_str='textcopy /S ' @srvname ' /U ' @login ' /P ' @password ' /D ' @dbname ' /T' @tbname ' /C ' @colname ' /W"' @whereclause '" /F"' @filename '" /' @direction¡¡¡¡EXEC master..xp_cmdshell @exec_str¡¡¡¡----------------------------------------------------¡¡¡¡¡¡¡¡insert dali values(1,0x,'doc','´óÁ¦µÄdoc') ---ÆäÖеڶþÁÐÊÇ 0x ËüÊÇÒ»¸ö16½øÖÆÊý¶ÔÓ¦imageÁÐ,ÊDZØÐëµÄ,²»ÒªÐ´null,µÚÈýÁÐÊÇÎļþÀàÐÍ£¬¼ÈÀ©Õ¹Ãû¡¡¡¡¡¡¡¡sp_textcopy 'ÄãµÄ·þÎñÆ÷Ãû','sa','ÄãµÄÃÜÂë','test','dali','MyImage','c:´óÁ¦µÄdoc.doc','where ID=1','I'¡¡¡¡-------ÒÀ´Î²ÎÊýÊÇ£ºÊµÀýÃû,Óû§Ãû,ÃÜÂ룬Êý¾Ý¿âÃû£¬±íÃû£¬imageÁÐÃû£¬Â·¾¶¼°ÎļþÃû£¬Ìõ¼þ(Äã±ØÐë±£Ö¤ËüֻѡÔñÒ»ÐÐ)£¬I¡¡¡¡---------------------------------------------------------------------------------------------------------------------¡¡¡¡insert dali values(2,0x,'bmp','ͼƬ')¡¡¡¡sp_textcopy 'ÄãµÄ·þÎñÆ÷Ãû','sa','ÄãµÄÃÜÂë','test','dali','MyImage','c:ͼƬ.bmp','where ID=2','I' --×¢ÒâÌõ¼þÊÇ ID=2¡¡¡¡¡¡¡¡insert dali values(3,0x,'xls','ExcelÎļþ')¡¡¡¡sp_textcopy 'ÄãµÄ·þÎñÆ÷Ãû','sa','ÄãµÄÃÜÂë','test','dali','MyImage','c:ExcelÎļþ.xls','where ID=3','I' --×¢ÒâÌõ¼þÊÇ ID=3¡¡¡¡¡¡¡¡insert dali values(4,0x,'htm','ÍøÒ³')¡¡¡¡sp_textcopy 'ÄãµÄ·þÎñÆ÷Ãû','sa','ÄãµÄÃÜÂë','test','dali','MyImage','c:ÍøÒ³.htm','where ID=4','I' --×¢ÒâÌõ¼þÊÇ ID=4¡¡¡¡¡¡¡¡----------ÉÏÃæµÄÓï¾ä,Òª±£Ö¤ÀàÐÍÒ»Ñù£¬Â·¾¶ÕýÈ·£¬Ìõ¼þΨһÕýÈ·Ó¦¸Ã¾Í¿ÉÒÔÁË¡¡¡¡¡¡¡¡6¡¢Ìî³äÈ«ÎÄË÷Òý¡¡¡¡¡¡¡¡sp_fulltext_table 'dali','start_full' ---µÚÒ»¸ö²ÎÊýÊDZíÃû£¬µÚ¶þ¸ö²ÎÊýÊÇÆô¶¯±íµÄÈ«ÎÄË÷ÒýµÄÍêÈ«Ìî³ä¡¡¡¡¡¡¡¡7¡¢¿ÉÒÔ¿ªÊ¼ÄãµÄʵÑéÁË¡¡¡¡¡¡¡¡select * from dali where contains(MyImage,'JÀÏʦ')¡¡¡¡¡¡¡¡select * from dali where contains(MyImage,'º£ÀÏʦ')¡¡¡¡¡¡¡¡------END----------¡¡¡¡--µ÷ÊÔ»·¾³£ºSQLServer2K¡¢Windows2Kas
±êÇ©£º