SQL Server TEXTÀàÐÍ×Ö¶Î×Ö·û´®Ì滻ʾÀý´¦Àí½Å±¾
/*--text×ֶεÄÌæ»»´¦Àí
--*/
--´´½¨Êý¾Ý²âÊÔ»·¾³
--create table #tb(aa text)
declare @s_str varchar(8000),@d_str varchar(8000), --¶¨ÒåÌæ»»µÄ×Ö·û´®
@p varbinary(16),@postion int,@rplen int,@i_Start int, @i_End int
select identity(int,1,1) as [id],newsid into # from news
select @i_Start=min([id]),@i_End=max([id]) from #
while (@i_Start<=@i_End)
begin
--insert into #tb(aa) select content from # where [id]=@i_Start
select @s_str='\' --ÒªÌæ»»µÄ×Ö·û´®
,@d_str='!' --Ìæ»»³ÉµÄ×Ö·û´®
--×Ö·û´®Ìæ»»´¦Àí
select @p=textptr(content),@rplen=len(@s_str),@postion=charindex(@s_str,content)-1 from news where newsid in (select top 1 newsid from # where [id]=@i_Start)
while @postion>0
begin
updatetext news.content @p @postion @rplen @d_str
select @postion=charindex(@s_str,content)-1 from news where newsid in (select top 1 newsid from # where [id]=@i_Start)
end
--truncate table #tb
select @i_Start=@i_Start+1
end
--ɾ³ýÊý¾Ý²âÊÔ»·¾³
--drop table #tb
drop table #
Ïà¹ØÎĵµ£º
--Óï ¾ä ¹¦ ÄÜ
--Êý¾Ý²Ù×÷
SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--Êý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý¿âÖÐɾ³ý±í
ALTER TABLE --ÐÞ¸ÄÊý¾Ý¿â±í½á¹¹
CREATE VIEW --´´½¨Ò»¸öÊÓÍ ......
and exists (select * from sysobjects) //ÅжÏÊÇ·ñÊÇMSSQL and exists(select * from tableName) //ÅжÏij±íÊÇ·ñ´æÔÚ..tableNameΪ±íÃû and 1=(select @@VERSION) //MSSQL°æ±¾ And 1=(select db_name()) //µ±Ç°Êý¾Ý¿âÃû and 1=(select @@servername) //±¾µØ·þÎñÃû and 1=(select IS_SRVROLEMEMBER('sysadmin')) ......
sqlÔÚ¶à·½ÃþË÷ºÍÅóÓѵİïÖúÏ£¬ÖÕÓÚ¿ÉÒÔÁ¬½Ó³É¹¦£¬Õâ¶ÔÎÒÀ´ËµÊǸöÀï³Ì±®À´µÄ£¬ÔÚ¹¤×÷µÄ¹ý³ÌÖÐÎÒ×ÜÊÇûÓлú»á¿ÉÒÔÅö´¥µ½SQL£¬µ±ÎÒ¹ÄÆðÓÂÆøÓÂÆøÏëѧϰµÄʱºòÎÒÁ¬ÔõôÓö¼²»»á£¬½øÀ´ÖÕÓÚÁ´½Ó³É¹¦£¬¿ªÐĵغÍÅóÓÑ·ÖÏíÎҵijɹû¡£
1.°²×°sql£¬Ñ§Ï°SQl£¬ÒòΪһ°ãÎÒÊÇÏëÒªÓÃÓÚVS2005ÏîÄ¿µÄ£¬ËùÒÔÒ»°ã×îºó¾ÍÏȰ²×°VSÈí¼þ£¬ÒÔ±ã ......
·½·¨Ò»£º
select distinct name from tablename
·½·¨¶þ£º
select min(fid),name,sex from tablename group by name
×ܼƣº
select distinct name from tablename ´ò¿ªÖظ´¼Ç¼µÄµ¥¸ö×Ö¶Î
select * from tablename where fid in(Select min(fid) from tablename group by name)´ò¿ªÖظ´¼Ç¼µÄËùÓÐ×Ö¶ÎÖµ
select ......