SQL´æ´¢¹ý³ÌÖÐSELECTÓëSET ¶Ô±äÁ¿¸³ÖµµÄÇø±ð
²Î¿¼£ºhttp://gaowenjie7758.blog.163.com/blog/static/5946788920091116244306/
SQL´æ´¢¹ý³ÌÖÐSELECTÓëSET ¶Ô±äÁ¿¸³ÖµµÄÇø±ð
SQL Server ÖжÔÒѾ¶¨ÒåµÄ±äÁ¿¸³ÖµµÄ·½Ê½ÓÃÁ½ÖÖ£¬·Ö±ðÊÇ SET ºÍ SELECT¡£¶ÔÓÚÕâÁ½ÖÖ·½Ê½µÄÇø±ð£¬SQL Server Áª»ú´ÔÊéÖÐÒѾÓÐÏêϸµÄ˵Ã÷£¬µ«ºÜ¶àʱºòÎÒÃDz¢Ã»ÓÐ×¢Ò⣬ÆäʵÕâÁ½ÖÖ·½Ê½»¹ÊÇÓкܶà²î±ðµÄ¡£SQL ServerÍƼöʹÓà SET ¶ø²»ÊÇ SELECT ¶Ô±äÁ¿½øÐи³Öµ¡£µ±±í´ïʽ·µ»ØÒ»¸öÖµ²¢¶ÔÒ»¸ö±äÁ¿½øÐи³ÖµÊ±£¬ÍƼöʹÓà SET ·½·¨¡£
ϱíÁгö SET Óë SELECT µÄÇø±ð¡£ÇëÌرð×¢ÒâºìÉ«²¿·Ö¡£
set
select
ͬʱ¶Ô¶à¸ö±äÁ¿Í¬Ê±¸³Öµ
²»Ö§³Ö
Ö§³Ö
±í´ïʽ·µ»Ø¶à¸öֵʱ
³ö´í
±¾ÈËÔÚ2005ÖвâÊÔ£¬Ò²±¨´í
±í´ïʽδ·µ»ØÖµ
±äÁ¿±»¸³nullÖµ
±¾ÈËÔÚ2005ÖвâÊÔ£¬±äÁ¿±»¸³nullÖµ
×ÛÉÏËùÊö£¬setºÍselectµÄÇø±ðÔÚÓÚ£¬selectÖ§³Öͬʱ¶Ô¶à¸ö±äÁ¿¸³Öµ£¬¶øset²»Ö§³Ö
Ïà¹ØÎĵµ£º
ÊìÁ·Ê¹ÓÃSQL ServerÖеĸ÷ÖÖÓ÷¨»á¸ø²éѯ´øÀ´ºÜ¶à·½±ã¡£½ñÌì¾Í½éÉÜÒ»ÏÂEXCEPTºÍINTERSECT¡£×¢Òâ´ËÓï·¨½öÔÚSQL Server 2005¼°ÒÔÉÏ°æ±¾Ö§³Ö¡£
EXCEPTÊÇÖ¸ÔÚµÚÒ»¸ö¼¯ºÏÖдæÔÚ£¬µ«ÊDz»´æÔÚÓÚµÚ¶þ¸ö¼¯ºÏÖеÄÊý¾Ý¡£
INTERSECTÊÇÖ¸ÔÚÁ½¸ö¼¯ºÏÖж¼´æÔÚµÄÊý¾Ý¡£
²âÊÔÈçÏ£º
create table t1(id int,mark char(2))
go
create ta ......
¼ì²âËÀËø
Èç¹û·¢ÉúËÀËøÁË£¬ÎÒÃÇÔõôȥ¼ì²â¾ßÌå·¢ÉúËÀËøµÄÊÇÄÄÌõSQLÓï¾ä»ò´æ´¢¹ý³Ì£¿
ÕâʱÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´洢¹ý³ÌÀ´¼ì²â£¬¾Í¿ÉÒÔ²é³öÒýÆðËÀËøµÄ½ø³ÌºÍSQLÓï¾ä¡£SQL Server×Ô´øµÄϵͳ´æ´¢¹ý³Ìsp_whoºÍsp_lockÒ²¿ÉÒÔÓÃÀ´²éÕÒ×èÈûºÍËÀËø, µ«Ã»ÓÐÕâÀï½éÉܵķ½·¨ºÃÓá£
use master
go
create procedure s ......
If the SQL data type is 'timestamp', we need to use ResultSet.getBytes() to retrieve its value. If the SQL data type is 'datetime', we can use ResultSet.getTimestamp(). It is said timestamp is interanlly saved as binary data.
try {
Class.forName("com.microsoft. ......
1. µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
select getdate()
2. dateadd ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
select dateadd(day,2,'2004-10-15') --·µ»Ø£º2004-10-17 00:00:00.000
3. datediff ·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£
select datediff(day,'2004-09-01','2004-09-18') --· ......
SQLÈÕÆÚʱ¼ä²»ÄÜÔçÓÚ1753Äê
1.¹«ÔªÔªÄêµÄµÚÒ»Ì죬Ҳ¾ÍÊǹ«Ôª1Äê1ÔÂ1ÈÕ£¬ÄÇÌìÊÇÐÇÆÚÁù¡£
2.
ÏÖÐеĹ«ÀúÊǸñÀû¸êÀïÀú·¨£¬Õâ¸öÀú·¨²¢²»ÊÇÁ¬ÐøµÄ£¬ÖмäȱÉÙÁË11Ìì¡£1752Äê9ÔÂ2ÈյĺóÒ»Ìì²¢²»ÊÇ9ÔÂ3ÈÕ£¬¶øÊÇ9ÔÂ14ÈÕ¡£Ò²¾ÍÊÇ˵£¬´Ó1752Äê9ÔÂ3ÈÕµ½9ÔÂ13ÈÕµÄ11Ìì²¢²»´æÔÚ¡£
&nb ......