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

sql server²éѯÊý¾Ý¿âÖаüº¬Ö¸¶¨×Ö·û´®µÄÊý¾Ý±í

 ·¢²¼Ò»¸öʵÓÃС¹¤¾ß£¬¿ÉÒԺܷ½±ãµÄÔÚÊý¾Ý¿âÖÐÕÒµ½°üº¬Ö¸¶¨×Ö·û´®µÄÊý¾Ý±íÃû¼°ÏàÓ¦¼Ç¼£º
/*
¹¦ÄÜ£º²éѯÊý¾Ý¿âÖаüº¬Ö¸¶¨×Ö·û´®µÄÊý¾Ý±íÃû¼°ÏàÓ¦¼Ç¼
×÷Õߣº³Â¼ÓÅô chjpeng#163.com
ÈÕÆÚ£º2009-08-17
*/
declare @key varchar(30)
set @key = 'test'    --Ìæ»»ÎªÒª²éÕÒµÄ×Ö·û´®
DECLARE @tabName VARCHAR(40),@colName VARCHAR(40)
DECLARE @sql VARCHAR(2000)
declare @tsql varchar(8000)
DECLARE tabCursor CURSOR FOR
SELECT name from sysobjects WHERE xtype = 'u' AND name <> 'dtproperties'
OPEN tabCursor
FETCH NEXT from tabCursor INTO @tabName
WHILE @@fetch_status = 0
BEGIN
 set @tsql = ''
 DECLARE colCursor CURSOR FOR Select Name from SysColumns Where id=Object_Id(@tabName) and xtype=167
 OPEN colCursor
 FETCH NEXT from colCursor INTO @colName
 WHILE @@fetch_status = 0
 BEGIN
  SET @sql = 'if(exists(select * from ' + @tabName + ' where '
  SET @sql = @sql + @colName + ' like ''%' + @key + '%'')) begin  select * from '
  set @sql = @sql + @tabName + ' where ' + @colName + ' like ''%' + @key + '%'';select '''
   + @tabName + ''' as TableName  end'
  set @tsql = @tsql + @sql + ';'
  FETCH NEXT from colCursor INTO @colName
 END
 exec(@tsql)
 CLOSE colCursor
 DEALLOCATE colCursor
 FETCH NEXT from tabCursor INTO @tabName
END
CLOSE tabCursor
DEALLOCATE tabCursor


Ïà¹ØÎĵµ£º

SQL ÓÅ»¯¾­Ñé×ܽá34Ìõ

£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLE µÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄǾÍÐèҪѡÔñ½»²æ±í(intersectio ......

SQL ServerºÍOracle³£Óú¯Êý¶Ô±È


Êýѧº¯Êý
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.È¡Õû£¨½ØÈ¡£©
S:select cast(-1.002 as in ......

ÕÒµ½ÒýÆð´ÅÅÌÅÅÐòµÄSQL

ÏÂÃæµÄÕâЩ½Å±¾¶¼¿ÉÒÔÕÒµ½ÒýÆð´ÅÅÌÅÅÐòµÄSQL¡£ 
SELECT /*+ rule */ DISTINCT a.SID, a.process, a.serial#,
TO_CHAR (a.logon_time, 'YYYYMMDD HH24:MI:SS') LOGON, a.osuser,TABLESPACE, b.sql_text
from v$session a, v$sql b, v$sort_usage c
WHERE a.sql_address = b.address AND a.saddr = c.session_addr; ......

SQL ÁÙʱ±íÓëÁÙʱ±äÁ¿±í

 
         ÔÚSQLServerµÄÐÔÄܵ÷ÓÅÖУ¬ÓÐÒ»¸ö²»¿É±ÈÄâµÄÎÊÌ⣺ÄǾÍÊÇÈçºÎÔÚÒ»¶ÎÐèÒª³¤Ê±¼äµÄ´úÂë»ò±»Æµ·±µ÷ÓõĴúÂëÖд¦ÀíÁÙʱÊý¾Ý¼¯?±í±äÁ¿ºÍÁÙʱ±íÊÇÁ½ÖÖÑ¡Ôñ¡£ÈçºÎÈ·¶¨Ê²Ã´Ê±ºòÓÃÁÙʱ±í£¬Ê²Ã´Ê±ºòÓñí±äÁ¿ÄØ£¿ÁÙʱ±íºÍ±í±äÁ¿¶¼ÓÐÌØ¶¨µÄÊÊÓû·¾³¡£
¡¡¡¡±í±äÁ¿
¡¡¡¡±äÁ¿¶ ......

SQL SERVERÖÐÁÙʱ±í¡¢³Ö¾Ã±í¡¢±í±äÁ¿µÄÇø±ð

 Óë³Ö¾Ã±íÒ»Ñù£¬ÓÅ»¯Æ÷´´½¨²¢Î¬»¤ÁÙʱ±íµÄ·Ö²¼Í³¼ÆÐÅÏ¢£¬²¢¸ú×ÙËüµÄ»ùÊý¡£µ±Ë÷ÒýÁÙʱ±íʱ£¬ÕâÖÖÄÜÁ¦ÓÈÆäÖØÒª¡£µ±ÓÅ»¯Æ÷ÐèÒªÆÀ¹ÀÑ¡ÔñÐÔʱ£¬Ëü¾Í¿ÉÒÔ¸ù¾ÝÕâЩ·Ö²¼Í³¼ÆÐÅÏ¢Éú³É¾­¹ýÓÅ»¯µÄ¼Æ»®¡£ÕâÊÇÁÙʱ±íÔÚÐÔÄÜ·½Ã治ͬÓÚ±í±äÁ¿µÄÖ÷ÒªÌØÐÔÖ®Ò»¡£
´ËÍ⣬ÒòΪÁÙʱ±í»áά»¤Í³¼ÆÐÅÏ¢£¬Èç¹ûÉϴαàÒëºó±»ÒýÓñíÓÐ×ã¹»¶àµÄÐз¢ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ