SQL Server³£Óú¯Êý
ÔÚÊý¾Ý¿â²éѯÊý¾Ýʱ£¬ÎÒÃǾ³£Ê¹ÓÃһЩº¯Êý£¬Ê¹ÎÒÃǵIJéѯ¸ü¼Ó·½±ã¿ì½Ý£¬ÏÂÃæ¾Í°ÑSQL ServerÖÐÎÒÃdz£Óõļ¸¸öº¯Êý¸øÁоٳöÀ´£¬¹©²Î¿¼¡£
1.×Ö·û´®º¯ÊýÓû§¿ØÖÆ·µ»Ø¸øÓû§µÄ×Ö·û´®£¬ÕâЩ¹¦ÄܽöÓÃÓÚ×Ö·ûÐÍÊý¾Ý¡£
2.ÈÕÆÚº¯ÊýÓÃÓÚ²Ù×÷ÈÕÆÚÖµ£¬ÎÒÃDz»ÄÜÖ±½Ó¶ÔÈÕÆÚÔËÓÃÊýѧº¯Êý¡£
3.Êýѧº¯ÊýÓÃÓÚ¶ÔÊýÖµ½øÐдúÊýÔËËã¡£
4.ϵͳº¯ÊýÓÃÀ´»ñÈ¡ÓйØSQL ServerÖжÔÏóºÍÉèÖõÄϵͳÐÅÏ¢¡£
º¯ Êý Ãû
Ãè Êö
¾Ù Àý
²¿·Ö³£ÓõÄ×Ö·û´®º¯Êý
Charindex
ÓÃÀ´Ñ°ÕÒÒ»¸öÖ¸¶¨µÄ×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖеÄÆðʼλÖÃ
Select charindex(‘accp’,’my accp course’,1)
·µ»Ø£º4
Len
·µ»Ø¸øËüµÄ×Ö·û´®³¤¶È
Select len(‘SQL server ¿Î³Ì’)
·µ»Ø£º12
Upper(lower)
°Ñ´«µÝ¸øËüµÄ×Ö·û´®×ª»»Îª´óд
Select upper(‘SQL server ¿Î³Ì’)
·µ»Ø£ºSQL SERVER ¿Î³Ì
Ltrim(rtrim)
Çå³ý×Ö·û×ó±ßµÄ¿Õ¸ñ
Select ltrim(‘ ×Ö·û ’)
·µ»Ø£º×Ö·û (ºóÃæµÄ¿Õ¸ñ±£Áô)
Right
´Ó×Ö·ûÓұ߷µ»ØÖ¸¶¨ÊýÄ¿µÄ×Ö·û
Select right(‘1234567890’,5)
·µ»Ø£º67890
Replace
Ìæ»»Ò»¸ö×Ö·û´®µÄ×Ö·û
Select replace(‘ÎÒ°®Äã’,’Äã’,’妳’)
·µ»Ø£ºÎÒ°®妳
Stuff
ÔÚÒ»¸ö×Ö·û´®ÖÐ,ɾ³ýÖ¸¶¨³¤¶ÈµÄ×Ö·û,²¢ÔÚ¸ÃλÖòåÈëÒ»¸öеÄ×Ö·û´®
Select stuff(‘ABCDEFG’,2,3,’À¶À¶µÄÌìÀ¶À¶µÄÃÎ’)
·µ»Ø£ºAÀ¶À¶µÄÌìÀ¶À¶µÄÃÎG
²¿·Ö³£ÓõÄÈÕÆÚº¯Êý
Getdate
È¡µÃµ±Ç°µÄϵͳÈÕÆÚ
Select getdate()
·µ»Ø£ºµ±Ç°µÄÈÕÆÚ,ʱ¼ä
Dateadd
½«Ö¸¶¨µÄÊýÖµÌí¼Óµ½Ö¸¶¨µÄÈÕÆÚ²¿·ÖºóµÄÈÕÆÚ
Select dateadd(mm,4,’2009-6-24’)
·µ»Ø£ºÒÔµ±Ç°ÈÕÆÚ¸ñʽ·µ»Ø2009-10-24
Datediff
Á½¸öÈÕÆÚÖ®¼äµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÇø±ð
Select datediff(mm,’2009-5-24’,’2009-10-24’)
·µ»Ø£º5
Datename
ÈÕÆÚÖÐÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®ÐÎʽ
Select datename(dw,2009-10-24)
·µ»Ø£ºÐÇÆÚÁù
Datepart
ÈÕÆÚÖÐÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊýÐÎʽ
Select datepart(day,’2009-10-24’)
·µ»Ø£º24
²¿·Ö³£ÓõÄÊýѧº¯Êý
Abs
È¡ÊýÖµ±í´ïʽµÄ¾ø¶ÔÖµ
Select abs(-60)
·µ»Ø£º60
Ceiling
È¡´óÓÚ»òµÈÓÚÖ¸¶¨ÊýÖµ¡¢±í´ïÖ®µÄ×îСÕûÊý
Select ceiling(19.5)
·µ»Ø£º20
Floor
ȡСÓÚ»òµÈÓÚÖ¸¶¨±í´ïʽµÄ×î´óÕ
Ïà¹ØÎĵµ£º
1.ÈçºÎ½«Ò»¸öSQL Server±íµÄ½á¹¹¸´ÖƵ½ÁíÒ»¸öн¨µÄ±íÖÐ
select * into бí from ¾É±í where 0 = 1
2.ÐÞ¸Ä×Ö¶ÎĬÈÏÖµ
alter table ±íÃû add default ĬÈÏÖµ for ×Ö¶ÎÃû
3. È¡µÃÊý¾Ý¿â½á¹¹
SELECT name from sysdatabases
4.Ôö¼ÓÁÐ
......
Ê×ÏÈÔÚsqlserverµÄ°²×°Â·¾¶Ï£¬È磺D:\Program Files\Microsoft SQL
Server\MSSQL\£¬ÕÒµ½ÎļþÃûÊÇscptxfr.exeµÄÎļþ,ÀûÓÃÃüÁîÐй¤¾ß£º¾ßÌåÓ÷¨ÈçÏ£º
D:\PROGRA~1\MICROS~2\MSSQL\>scptxfr/?
ÃüÁîÐÐÓï·¨:
SCPTXFR /s
<·þÎñÆ÷> /d <Êý¾Ý¿â> {[/I] | [/P <ÃÜÂë>]}
&n ......
C#ÖвÙ×÷OracleʱµÄSQLÓï¾ä²ÎÊýµÄÓ÷¨
OracleTransaction myTrans ;
conn.Open();
myTrans =conn.BeginTransaction(IsolationLevel.ReadCommitted) ......
¡¡ÎÒ¹«Ë¾ÔÚ×齨¾ÖÓòÍøʱ£¬¿¼Âǵ½ÉÌÒµÆóÒµµÄÌص㣬×Ðϸ¿¼Á¿Á˹º¡¢Ïú¡¢´æÈý´ó»·½ÚÖз¢ÉúµÄ¸÷ÖÖÊý¾Ý¼°Æä´æ´¢ÎÊÌâºó£¬Ñ¡¶¨ÁËÒÔWindows 2000 ServerΪ²Ù×÷ϵͳ£¬SQL Server 2000ΪÊý¾Ý¿âƽ̨À´´î½¨¾ÖÓòÍøµÄÓ¦ÓÃϵͳµÄÈí¼þƽ̨£¬ÒÔÍøÏßΪÔØÌ彫¹º¡¢Ïú¡¢´æµÈºËÐIJ¿ÃŵļÆËã»úͨ¹ý¾ÖÓòÍøƽ̨½ôÃܵØÁ¬½ÓÆðÀ´¡£ÕâÑù£¬¸÷¸öºËÐIJ¿ÃÅÿÌì ......
1.»ñÈ¡ËùÓÐÊý¾Ý¿âÃû:
SELECT Name from Master..SysDatabases ORDER BY Name
2.»ñÈ¡ËùÓбíÃû:
SELECT Name from DatabaseName..SysObjects Where XType='U' ORDER BY Name
XType='U':±íʾËùÓÐÓû§±í;
XType='S':±íʾËùÓÐϵͳ±í;
3.»ñÈ¡ËùÓÐ×Ö¶ÎÃû:
SELECT Name from SysColumns WHERE id=Object_Id('TableNam ......