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

SQL_³£ÓÃÓï¾ä

1¡¢SELECT ²éѯÓï¾äºÍÌõ¼þÓï¾ä
 
SELECT  ²éѯ×ֶΠfrom ±íÃû WHERE Ìõ¼þ
²éѯ×ֶΣº¿ÉÒÔʹÓÃͨÅä·û* ¡¢×Ö¶ÎÃû¡¢×ֶαðÃû
±íÃû£º Êý¾Ý¿â.±íÃû £¬±íÃû
³£ÓÃÌõ¼þ£º = µÈÓÚ ¡¢<>²»µÈÓÚ¡¢in °üº¬ ¡¢ not in ²»°üº¬¡¢ like Æ¥Åä
      BETWEEN  ÔÚ·¶Î§  ¡¢ not BETWEEN  ²»ÔÚ·¶Î§  < ¡¢>
¼þÔËË㣺 and ¡¢ or ¡¢ ( )
2¡¢ÅÅÐò,·Ö×é,Ö¸Õë²éѯ,¼ÆËã
 
·Ö×éÓï¾ä£ºgroup by ×Ö¶Î
ÅÅÐòÓï¾ä£ºorder by ×ֶΣ¬×ֶΠASC / DESC
Ö¸Õë²éѯ£ºlimit ³õʼֵ£¬½áÊøÖµ
¼ÆË㣺
  COUNT(*) ͳ¼Æº¯Êý
  MAX(*) ×î´óÖµº¯Êý
  MIN (*) ×îСֵº¯Êý
  AVG(*) ƽ¾ùÖµº¯Êý
  SUM(*) ÀÛ¼ÆÖµº¯Êý£¨∑£©
3¡¢Insert ²åÈëÓï¾ä
 
insert into ±íÃû (×ֶ΅,…) values(Öµ…,…)
insert into ±íÃû values(Öµ…,…)
²åÈëʱÐ뿼ÂÇÇå³þ×Ö¶ÎÀàÐͱÜÃâ²åÈëºó³öÏÖȱֵ£¬ÂÒÂëÏÖÏó
 
4¡¢Update ¸üÐÂÓï¾ä
 
UPDATE ±íÃû SET ×ֶΠ= Öµ WHERE Ìõ¼þ limit 
 
5¡¢Delete  ɾ³ýÓï¾ä
 
DELETE  from ±íÃû WHERE Ìõ¼þ limit


Ïà¹ØÎĵµ£º

SQL SERVER 2005ÖеÄÈÕÆÚʱ¼äÀàÐÍ

 
 
SQL SERVER 2005 ÖеÄÈÕÆÚʱ¼äÀàÐÍ
Ò»£®  Êý¾ÝÀàÐÍ
MS SQL Server 2005 ÓÐ datetime ºÍ smalldatetime Á½ÖÖ¸ñʽµÄÈÕÆÚʱ¼äÊý¾ÝÀàÐÍ¡£×¢Ò⣺ûÓе¥¶ÀµÄÈÕÆÚ»òʱ¼äÀàÐÍ¡£
 
datetime
Êý¾Ý¿âÄÚ²¿ÓÃÁ½¸ö 4 ×Ö½ÚµÄÕûÊý´æ´¢ datetime Êý¾ÝÀàÐ͵ÄÖµ¡£µÚÒ»¸ö 4 ×Ö½Ú´æ´¢»ù´¡ÈÕÆÚ£¨¼´ 1900-1-1, base ......

Sql Server ÖÐÒ»¸ö·Ç³£Ç¿´óµÄÈÕÆÚ¸ñʽ»¯º¯Êý

Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06
Select CONVERT(varchar(100), GETDATE(), 4): 16.05.06
Select CONVERT(varch ......

SQLʵÏÖÍêÈ«ÅÅÁÐ×éºÏ

---SQLʵÏÖÍêÈ«ÅÅÁÐ×éºÏ
create function F_strSpit(@s varchar(200)) returns table
as
return(
select value=substring(@s,i,num)+substring(@s,num-1+j,1)
from (select num=number from spt_values where type='p' and number<len(@s) and number>0)TA,
(select i=number+1 from spt_values where type='p ......

Sql server´æ´¢¹ý³ÌÖÐ Êý¾Ý¼¯µÄ»º´æ

create procedure DeleteWareHouse_StoreArea_SummaryByPUR
(@po_no nvarchar(100))
as
begin
declare @cacheTable table(wh_id int);--ÉùÃ÷Ò»¸ötableÀàÐ͵ıäÁ¿
insert @cacheTable select wh_id from aps_inventory_store_area where description=@po_no--Ïò±äÁ¿@cacheTableÖÐÌí¼Ó½á¹û¼¯
--select * from @cac ......

³£ÓÃSqlÓï¾ä

ʹÓà TRUNCATE TABLE ɾ³ýËùÓÐÐÐ
ÈôҪɾ³ý±íÖеÄËùÓÐÐУ¬Ôò TRUNCATE TABLE Óï¾äÊÇÒ»ÖÖ¿ìËÙ¡¢ÓÐЧµÄ·½·¨¡£TRUNCATE TABLE Óë²»º¬ WHERE ×Ó¾äµÄ DELETE Óï¾äÀàËÆ¡£µ«ÊÇ£¬TRUNCATE TABLE Ëٶȸü¿ì£¬²¢ÇÒʹÓøüÉÙµÄϵͳ×ÊÔ´ºÍÊÂÎñÈÕÖ¾×ÊÔ´¡£
Óë DELETE Óï¾äÏàͬ£¬Ê¹Óà TRUNCATE TABLE Çå¿ÕµÄ±íµÄ¶¨ÒåÓëÆäË÷ÒýºÍÆäËû¹ØÁª¶ÔÏóÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ