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

ÍâÁ¬½ÓsqlµÄÒ»¸öÎÊÌâ

µ±ÔÚÄÚÁ¬½Ó²éѯÖмÓÈëÌõ¼þʱ£¬ÎÞÂÛÊǽ«Ëü¼ÓÈëµ½join×Ӿ䣬»¹ÊǼÓÈëµ½where×Ӿ䣬ÆäЧ¹ûÊÇÍêÈ«Ò»ÑùµÄ£¬µ«¶ÔÓÚÍâÁ¬½ÓÇé¿ö¾Í²»Í¬ÁË¡£µ±°ÑÌõ¼þ¼ÓÈëµ½ join×Ó¾äʱ£¬»á·µ»ØÍâÁ¬½Ó±íµÄÈ«²¿ÐУ¬È»ºóʹÓÃÖ¸¶¨µÄÌõ¼þ·µ»ØµÚ¶þ¸ö±íµÄÐС£Èç¹û½«Ìõ¼þ·Åµ½where×Ó¾äÖУ¬½«»áÊ×ÏȽøÐÐÁ¬½Ó²Ù×÷£¬È»ºóʹÓÃwhere×Ó¾ä¶ÔÁ¬½ÓºóµÄÐнøÐÐɸѡ¡£ÀýÈ磺
£¨1£©
select u.id, u.p_plan_id, u.unit_name, p.id, p.plan_name
  from t_baidu_p_units u
  left outer join t_baidu_p_plans p on u.p_plan_id = p.id
                                   and p.id = 3176
 where 1 = 1
 order by u.p_plan_id desc
Ëü»á·µ»Øt_baidu_p_units±íÖÐËùÓÐÐУ¬t_baidu_p_plans±íÖзûºÏjoinÌõ¼þµÄ×ֶβ»Îªnull
£¨2£©
select u.id, u.p_plan_id, u.unit_name, p.id, p.plan_name
  from t_baidu_p_units u
  left outer join t_baidu_p_plans p on u.p_plan_id = p.id
                                   and p.id = 3176
 where p.id is null
 order by u.p_plan_id desc
²éѯµÄ½á¹û¼¯ÖÐûÓзûºÏjoinÌõ¼þµÄÊý¾Ý
£¨3£©
select u.id, u.p_plan_id, u.unit_name, p.id, p.plan_name
  from t_baidu_p_units u
  left outer join t_baidu_p_plans p on u.p_plan_id = p.id
                                   and p.id = 3176
 where p.id is not null
 order by u.p_plan_id desc
½á¹û¼¯ÖÐÖ»°üº¬joinÌõ¼þµÄÊý¾Ý
·ÖÎöһϣº
  £¨1£©where1=1¶ÔÆä½øÐйýÂËʱ£¬ÓÉÓÚ¶¼·ûºÏ´ËÌõ¼þ£¬Òò´ËûÓиıä½á¹û¼¯
  £¨2£©¸ù¾Ýwhere p.id is null¶ÔÓÚjoinºóµÄ½á¹û¼¯½øÐÐɸѡ£¬·²ÊÇp.id²»ÎªnullµÄ¶¼Òª¹ýÂ˵ô£¬Òò´Ë×ÔȻûÓÐp.id=3176µÄ½á¹û
  £¨


Ïà¹ØÎĵµ£º

EXCELתÊý¾Ýµ½SQL(ÒÑÓбí½á¹¹)

insert into Country123 ([Country_Id], [Region_ID], [Country_EN_Name], [Country], [Country_ALL_ID], [Country_Order_Id]) select [Country_Id], [Region_ID], [Country_EN_Name], [Country], [Country_ALL_ID], [Country_Order_Id] from openrowset( 'Microsoft.Jet.OLEDB.4.0', 'EXCEL 5.0;HDR=YES;IMEX=1; DATABASE= ......

·ÀÖ¹SQL×¢Èë

Ô­ÎĵØÖ·:http://hi.baidu.com/%BC%D9%BA%EC%D2%B6%CE%E8%CE%F7%B7%E7/blog/item/81f35da209e287abcbefd005.html
1. ʲôÊÇSQL×¢Èë
ËùνSQL×¢È룬¾ÍÊÇͨ¹ý°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÝ½»»òÊäÈëÓòÃû»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬×îÖÕ´ïµ½ÆÛÆ­·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁͨ¹ýµÝ½»²ÎÊý¹¹ÔìÇÉÃîµÄSQLÓï¾ä£¬´Ó¶ø³É¹¦»ñÈ¡ÏëÒªµÄÊý¾Ý¡£
......

ÈçºÎʶ±ð SQL Server µÄ°æ±¾¡¾×ª×Ômsdn¡¿

ÈçºÎÈ·¶¨ËùÔËÐÐµÄ SQL Server 2005 µÄ°æ±¾
Ҫȷ¶¨ËùÔËÐÐµÄ SQL Server 2005 µÄ°æ±¾£¬ÇëʹÓà SQL Server Management Studio Á¬½Óµ½ SQL Server 2005£¬È»ºóÔËÐÐÒÔÏ Transact-SQL Óï¾ä£º
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
ÔËÐнá¹ûÈçÏ£º
²úÆ·° ......

SQL Server 2005Óë2000Ö®¼äµÄÊý¾Ýת»»

¡¡2005²»ÂÛÊÇÐÔÄÜ»¹ÊÇ°²È«ÐÔ¶¼ÊÇSQL SERVER2000ÓÐËùÔöÇ¿£¬ÏÖÓв»ÉÙÆóÒµÔÚʹÓÃ2005£¬»òÊÇÓеÄÓû§ÊÇ2000Óë2005ͬʱʹÓã¬ÄÇôÕâÖмä¾ÍÉæ¼°µ½Ë«Êý¾ÝµÄת»»ÎÊÌ⣺
¡¡¡¡½ñÌìÎÒÃǾÍÀ´¿´Ò»ÏÂÏà¹ØµÄʵÏÖ·½·¨£º
¡¡¡¡±¾È˵ÄʵÏÖ»·¾³½éÉÜ£º
¡¡¡¡·½·¨Ò»£º ʹÓ÷ÖÀëÓ븽¼Ó¡¡ ¸Ã·½·¨ÊʺÏÓÚ½«SQL Server 2000ÖеÄÊý¾Ýת»»µ½SQL Server2 ......

sql»ñÈ¡ÈÕÆÚ

declare
 @aa varchar(20)
set @aa= CONVERT(varchar(100), GETDATE(), 23)
--//ÈÕ
print @aa+' 0:00:00.000'
print @aa+' 23:59:59.999'
--//ÖÜ
print CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate()), 0), 23)+' 0:00:00.000'
print CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ