½â¾ö²¢Çå³ýSQL±»×¢Èë¶ñÒⲡ¶¾´úÂëµÄÓï¾ä
declare @t varchar(255),@c varchar(255)
declare table_cursor cursor for select a.name,b.name
from sysobjects a,syscolumns b ,systypes c
where a.id=b.id and a.xtype='u' and c.name
in ('char', 'nchar', 'nvarchar', 'varchar','text','ntext')
declare @str varchar(500),@str2 varchar(500)
set @str='<script src=http://r01.3322.org/c.js></script>'/*ÒªÌæ»»µÄÄÚÈÝ*/
set @str2=''
open table_cursor
fetch next from table_cursor
into @t,@c while(@@fetch_status=0)
begin exec('update [' + @t + '] set [' + @c + ']=replace(cast([' + @c + '] as varchar(8000)),'''+@str+''','''+ @str2 +''')')
fetch next from table_cursor
into @t,@c end close table_cursor deallocate table_cursor;
Ïà¹ØÎĵµ£º
1 Âß¼Êý¾Ý¿âºÍ±íµÄÉè¼Æ
Êý¾Ý¿âµÄÂß¼Éè¼Æ¡¢°üÀ¨±íÓë±íÖ®¼äµÄ¹ØϵÊÇÓÅ»¯¹ØϵÐÍÊý¾Ý¿âÐÔÄܵĺËÐÄ¡£Ò»¸öºÃµÄÂß¼Êý¾Ý¿âÉè¼Æ¿ÉÒÔΪ
ÓÅ»¯Êý¾Ý¿âºÍÓ¦ÓóÌÐò´òÏÂÁ¼ºÃµÄ»ù´¡¡£
±ê×¼»¯µÄÊý¾Ý¿âÂß¼Éè¼Æ°üÀ¨ÓöàµÄ¡¢ÓÐÏ໥¹ØϵµÄÕ±íÀ´´úÌæºÜ¶àÁеij¤Êý¾Ý±í¡£ÏÂÃæÊÇһЩʹÓñê×¼»¯
±íµÄһЩºÃ´¦¡£
A:ÓÉÓÚ±íÕ£¬Òò´Ë¿ÉÒÔʹŠ......
SELECT DISTINCT '['+user_name(b.uid)+'].['+b.name+']' AS ¶ÔÏóÃû,b.type AS ÀàÐÍ
from sysdepends a,sysobjects b
WHERE b.id=a.depid
AND a.id=OBJECT_ID('¹ý³ÌÃû');
EXEC SP_DEPENDS '¹ý³ÌÃû';
......
exists £¨sql ·µ»Ø½á¹û¼¯ÎªÕ棩
not exists (sql ²»·µ»Ø½á¹û¼¯ÎªÕ棩
ÈçÏ£º
±íA
ID NAME
1 A1
2 A2
3 A3
±íB
ID AID NAME
1 1 B1
2 2 B2
3 2 B3
±íAºÍ±íBÊÇ£±¶Ô¶àµÄ¹Øϵ A.ID => B.AID
......
SQL Server 2008 ¸´ÖÆ ·ÖÇøSWITCHÇåÀíÊý¾Ý
³¡¾°£º
ijÖÖÌض¨ÒµÎñÏ£¬ÎÒÃǵIJ¿·ÖÒµÎñÊý¾Ý¿ÉÄÜÖ»»á±£Áô±È½Ï¶ÌµÄʱ¼ä£¬ÓÃÀ´×öÁÙʱ´¦Àí¡£ÒòΪ¿¼ÂǸ߿ÉÓõÄÌØÐÔ£¬¿ÉÄÜ»áÀûÓÃ
SQL ServerµÄ¸´ÖÆ×é¼þ¸´ÖÆÕâÖÖÊý¾Ýµ½ÁíÍâµÄ ÀàËÆÇ°¶Ë£¬²éѯÖÐÐĵÈÊý¾Ý¿â·þÎñÆ÷£¬´´½¨Ò»¸öÈßÓั±¾¡£¸´ÖÆ×é¼þ±ê¼ÇÊÂÎñÈÕÖ¾£¬×·×ÙËùÓеÄUpdate£¬In ......