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

SQL¾­µä¶ÌС´úÂëÊÕ¼¯ 2

sqlserverµÄ¼¸¸öº¯ÊýÒª¼Ç¼
½ñÈÕÅöµ½¸öÎÊÌ⣺ҪʵÏÖÊý¾Ý±íÖеÄÒ»¸ö×Ö¶ÎÖеÄÎı¾Îª"xxx.gif"µÄת»»Îª"xxx.jpg",ÎÒ²»ÖªµÀÆä¾ßÌåÃû³Æ£¬Ö»ÖªµÀÊÇÒÔgif½áβ¡£
ÎÊÌâ½â¾ö£ºupdate pet set petPhoto=substring(petPhoto,1,datalength(petPhoto)-3)+'jpg' where petPhoto like '%.gif'
×¢ÒâÆ¥Åä·û£º“%”ΪƥÅäÈÎÒⳤ¶ÈÈÎÒâ×Ö·û,“_”Æ¥Åäµ¥¸öÈÎÒâ×Ö·û£¬[A]Æ¥ÅäÒÔA¿ªÍ·µÄ£¬[^A]Æ¥Åä³ý¿ªÒÔA¿ªÍ·µÄ¡£ÖªµÀº¯ÊýÊǽâ¾öÎÊÌâµÄ¹Ø¼ü£¨ÒÔÏÂת×ÔÍøÂ磩£º
1£¬Í³¼Æº¯Êý avg, count, max, min, sum
2£¬ Êýѧº¯Êý
ceiling£¨n) ·µ»Ø´óÓÚ»òÕßµÈÓÚnµÄ×îСÕûÊý
floor(n), ·µ»ØСÓÚ»òÕßÊǵÈÓÚnµÄ×î´óÕûÊý
round(m,n), ËÄÉáÎåÈë,nÊDZ£ÁôСÊýµÄλÊý
abs(n) ¾ø¶ÔÖµ
sign(n), µ±n>0, ·µ»Ø1£¬n=0,·µ»Ø0£¬n<0, ·µ»Ø-1
PI(), 3.1415....
rand(),rand(n), ·µ»Ø0-1Ö®¼äµÄÒ»¸öËæ»úÊý
3£¬×Ö·û´®º¯Êý
ascii(), ½«×Ö·ûת»»ÎªASCIIÂë, ASCII('abc') = 97
char(), ASCII Âë ת»»Îª ×Ö·û
low()£¬upper() ´óСдת»»
str(a,b,c)ת»»Êý×ÖΪ×Ö·û´®¡£ a,ÊÇҪת»»µÄ×Ö·û´®¡£bÊÇת»»ÒÔºóµÄ³¤¶È£¬cÊÇСÊýλÊý¡£str(123.456,8,2) = 123.46
ltrim(), rtrim() È¥¿Õ¸ñ ltrimÈ¥×ó±ßµÄ¿Õ¸ñ,rtrimÈ¥ÓұߵĿոñ
left(n), right(n), substring(str, start,length) ½ØÈ¡×Ö·û´®
charindex(×Ó´®£¬Ä¸´®£©£¬²éÕÒÊÇ·ñ°üº¬¡£ ·µ»ØµÚÒ»´Î³öÏÖµÄλÖã¬Ã»Óзµ»Ø0
patindex('%pattern%', expression) ¹¦ÄÜͬÉÏ£¬¿ÉÊÇʹÓÃͨÅä·û
replicate('char', rep_time), Öظ´×Ö·û´®
reverse(char),µßµ¹×Ö·û´®
replace(str, strold, strnew) Ìæ»»×Ö·û´®
space(n), ²úÉún¸ö¿ÕÐÐ
stuff(), SELECT STUFF('abcdef', 2, 3, 'ijklmn') ='aijklmnef', 2ÊÇ¿ªÊ¼Î»Öã¬3ÊÇÒª´ÓÔ­À´´®ÖÐɾ³ýµÄ×Ö·û³¤¶È£¬ijlmnÊÇÒª²åÈëµÄ×Ö·û´®¡£
3£¬ÀàÐÍת»»º¯Êý:
cast, cast( expression as data_type), Example:
SELECT SUBSTRING(title, 1, 30) AS Title, ytd_sales from titles WHERE CAST(ytd_sales AS char(20)) LIKE '3%'
convert(data_type, expression)
4,ÈÕÆÚº¯Êý
day(), month(), year()
dateadd(datepart, number, date), datapartÖ¸¶¨¶ÔÄÇÒ»²¿·Ö¼Ó£¬numberÖªµÀ¼Ó¶àÉÙ£¬dateÖ¸¶¨ÔÚË­µÄ»ù´¡Éϼӡ£datepartµÄÈ¡Öµ°üÀ¨£¬year,quarter,month,dayofyear,day,week,hour,minute,second,±ÈÈçÃ÷Ìì dateadd(day,1, getdate())
datediff(datepart,date1,date2). datapartºÍÉÏÃæÒ»Ñù¡


Ïà¹ØÎĵµ£º

SQL Server 2005/2008Êý¾Ý¿âÓʼþ

Æô¶¯Êý¾Ý¿âÓʼþ¹¦ÄÜ
 
sp_configure 'show advanced', 1;
GO
RECONFIGURE;
GO
sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE;
GO
 
 
 
 -- ÅäÖÃÊý¾Ý¿âÓʼþ
 -- Ìí¼ÓÓʼþÕË»§
execute msdb.dbo.sysmail_add_account_sp
    @account_name = 'ÓÊÏäÕ ......

¹ØÓÚDB2 sql:0206n ´íÎó

½ñÌìÅöµ½Ò»¸ösql:0206nµÄ´íÎó£¬ÎÒʹÓÃselect * from xxx¿ÉÒԲ鿴±í½á¹¹ºÍÄÚÈÝ£¬È»¶øµ±ÎÒʹÓÃselect aaa from xxxµÄʱºòÈ´¸øÎÒ±¨´í£¬×îºóÅŲéÔ­ÒòÊÇÎÒʹÓù¤¾ß½¨±í£¬½¨±íÓï¾äÊÇÀàËÆÕâÑùµÄ£ºcreate table("id" int,"name" varchar)£¬ºÃÁ˽á¹û¾ÍÊÇ×ֶθø¼ÓÁËÒýºÅ£¬ÔÚ²éѯµÄʱºòʹÓÃ*¿ÉÒÔ²éѯ£¬Ê¹Óõ¥¸ö×ֶβ»Äܲéѯ£¬ÎÒ¹À¼Æ¾ÍÊ ......

±È½ÏOracle SQLÖеÄIN & EXISTS

ÔÚOracle SQLÖÐÈ¡Êý¾ÝʱÓÐʱҪÓõ½in ºÍ exists ÄÇôËûÃÇÓÐʲôÇø±ðÄØ£¿
1 ÐÔÄÜÉϵıȽÏ
±ÈÈçSelect * from T1 where x in ( select y from T2 )
Ö´ÐеĹý³ÌÏ൱ÓÚ:
select *
  from t1, ( select distinct y from t2 ) t2
 where t1.x = t2.y;
숦﵀
select * from t1 where exists ( select null fro ......

SQL×éºÏ²éѯ¼°ÏȺó˳Ðò¶ÔЧÂʵÄÓ°Ïì

ÔÚSQL¿ç±í×éºÏ²éѯ´æÔÚЧÂÊÎÊÌ⣬¾ÙÀý±ÈÈç
delete from media_source where movie_id in ( select media_id from media where type=2 ) and origin = 3;
ºÍ
delete from media_source where origin = 3 and movie_id in ( select media_id from media where type=2 );
µÄЧÂÊÊDz»Ò»ÑùµÄ¡£
Èôorigin=3µÄÇé¿öÏÂmedia_so ......

SQL Server·ÖÒ³3ÖÖ·½°¸

 SQL Server·ÖÒ³3ÖÖ·½°¸±ÈÆ´
´ËתÔØÔ´×ÔÀîºé¸ùµÄblog.×÷ÕßÊÇ΢ÈíµÄMVP!Ï£Íû´ó¼Ò²Î¿¼ÒÔÏÂ3ÖÖ·½°¸,°´Êµ¼ÊÇé¿öÑ¡Ôñ!
½¨Á¢±í£º
CREATE TABLE [TestTable] (
 [ID] [int] IDENTITY (1, 1) NOT NULL ,
 [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
 [LastName] [nvarchar] (100) ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ