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

¾­µäÓÐÓõÄSQLÓï¾äÊÕ¼¯

1.˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb)
SQL: select * into b from a where 11
2.˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d,e,f from a;
3.˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
4.˵Ã÷£ºÍâÁ¬½Ó²éѯ(±íÃû1£ºa ±íÃû2£ºb)
SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUTER JOIN b ON a.a = b.c
5.˵Ã÷£ºÈճ̰²ÅÅÌáÇ°Îå·ÖÖÓÌáÐÑ
SQL: select * from Èճ̰²ÅÅ where datediff(’minute’,f¿ªÊ¼Ê±¼ä,getdate())>5
6.˵Ã÷£ºÁ½ÕŹØÁª±í£¬É¾³ýÖ÷±íÖÐÒѾ­ÔÚ¸±±íÖÐûÓеÄÐÅÏ¢
SQL:
delete from info where not exists ( select * from infobz where info.infid=infobz.infid )
˵Ã÷£º–
SQL:
SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE
from TABLE1,
(SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE
from (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND
from TABLE2
WHERE TO_CHAR(UPD_DATE,’YYYY/MM’) = TO_CHAR(SYSDATE, ‘YYYY/MM’)) X,
(SELECT NUM, UPD_DATE, STOCK_ONHAND
from TABLE2
WHERE TO_CHAR(UPD_DATE,’YYYY/MM’) =
TO_CHAR(TO_DATE(TO_CHAR(SYSDATE, ‘YYYY/MM’) || ‘/01′,’YYYY/MM/DD’) - 1, ‘YYYY/MM’) ) Y,
WHERE X.NUM = Y.NUM £¨+£©
AND X.INBOUND_QTY + NVL(Y.STOCK_ONHAND,0) X.STOCK_ONHAND ) B
WHERE A.NUM = B.NUM
˵Ã÷£º–
SQL:
select * from studentinfo where not exists(select * from student where studentinfo.id=student.id) and ϵÃû³Æ=’”&strdepartmentname&”‘ and רҵÃû³Æ=’”&strprofessionname&”‘ order by ÐÔ±ð,ÉúÔ´µØ,¸ß¿¼×ܳɼ¨
7.˵Ã÷£º
´ÓÊý¾Ý¿âÖÐÈ¥Ò»ÄêµÄ¸÷µ¥Î»µç»°·Ñͳ¼Æ(µç»°·Ñ¶¨¶îºØµç»¯·ÊÇåµ¥Á½¸ö±íÀ´Ô´£©
SQL:
SELECT a.userper, a.tel, a.standfee, TO_CHAR(a.telfeedate, ‘yyyy’) AS telyear,
SUM(decode(TO_CHAR(a.telfeedate, ‘mm’), ‘01′, a.factration)) AS JAN,
SUM(decode(TO_CHAR


Ïà¹ØÎĵµ£º

SQL Server¹ÜÀí³£ÓÃSQLÓï¾ä

1. ²é¿´Êý¾Ý¿âµÄ°æ±¾       
¡¡¡¡ select @@version
¡¡¡¡2. ²é¿´Êý¾Ý¿âËùÔÚ»úÆ÷²Ù×÷ϵͳ²ÎÊý       
¡¡¡¡exec master..xp_msver
¡¡¡¡3. ²é¿´Êý¾Ý¿âÆô¶¯µÄ²ÎÊý        
¡¡¡¡sp_configure
¡¡¡¡4 ......

SQLʱ¼ä¶Î²éѯ


SQLʱ¼ä¶Î²éѯ
ACCESSµÄ»°
select * from table where date1<#2008-1-20# and date2>#2007-8-30#
MYSQLµÄ»°
select * from table where date1<'2008-1-20' and date2>'2007-3-30'
Ò²¿ÉÒÔ
select * from table where date1 between '2008-1-20' and '2007-3-30'
ÆäÖÐdate1,date2¶¼ÊÇÈÕÆÚÀàÐ͵Ä× ......

SQL Server 2005 ÎÊÌ⣺TCP/IPÎÞ·¨Á¬½Ó

 ¸ÕÅöµ½Õâ¸öÎÊÌâʱ£¬ÒÔΪÊÇÓ¦Ó÷þÎñÆ÷ºÍÊý¾Ý¿â·þÎñÆ÷ûÁ¬Í¨£¬²éÁË°ëÌìµÄÍøÂç½á¹ûÍøÉÏÒ»²é£¬¸úSQL Server 2005Óйأ¬ÄãÌ«ÑôµÄ£¡
  ¿ªÊ¼²Ëµ¥-SQLServer2005-ÅäÖù¤¾ß-SQL Server Configuration Manager-SQLserver2005ÍøÂçÅäÖÃ-MSSQLSERVERµÄЭÒé-Ë«»÷TCP/IPЭÒé
  °ÑIP¸Ä³Éµ±Ç°Ê¹Óõģ¬µ±È»£¬¶Ë¿ÚҲҪȷ±£ ......

SQL ServerµÄ»Ö¸´Ä£Ê½

»Ö¸´Ä£Ê½£¨Recovery Model£©Ö¼ÔÚ¿ØÖÆÊÂÎñÈÕ־ά»¤¡£»Ö¸´Ä£Ê½ËµÃ÷Á˹¤×÷¶ªÊ§µÄ·çÏÕ£¬ÄÜ·ñ»Ö¸´µ½Ê±µã£¿ 
SQL ServerÊý¾Ý¿âÓÐÈýÖÖ»Ö¸´Ä£Ê½£º¼òµ¥»Ö¸´Ä£Ê½¡¢ÍêÕû»Ö¸´Ä£Ê½ºÍ´óÈÝÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½¡£
Ïà¶ÔÓÚ¼òµ¥»Ö¸´Ä£Ê½¶øÑÔ£¬ÍêÕû»Ö¸´Ä£Ê½ºÍ´óÈÝÁ¿ÈÕÖ¾»Ö¸´Ä£Ê½ÌṩÁ˸üÇ¿µÄÊý¾Ý±£»¤¹¦ÄÜ¡£ÕâЩ»Ö¸´Ä£Ê½¶¼ÊÇ»ùÓÚ±¸·ÝÊÂÎñÈÕÖ ......

SQLÈÕÆÚ¸ñʽת»»

from: http://blog.163.com/ck275601774/blog/static/1230468012009631113559291/
--ÈÕÆÚת»»²ÎÊý
select CONVERT(varchar,getdate(),120)
--2009-03-15 15:10:02
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
--20090315151201
select CONVERT(varchar(12) , getdate ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ