Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : mssql

mssql´æ´¢¹ý³ÌÊÕ¼¯


sql´æ´¢¹ý³Ì½Ì³Ì
[ËѼ¯ÕûÀí]sql´æ´¢¹ý³ÌÍêÈ«½Ì³Ì 
Ŀ¼
1.sql´æ´¢¹ý³Ì¸ÅÊö
2.SQL´æ´¢¹ý³Ì´´½¨
3.sql´æ´¢¹ý³Ì¼°Ó¦ÓÃ
4.¸÷ÖÖ´æ´¢¹ý³ÌʹÓÃÖ¸ÄÏ
5.ASPÖд洢¹ý³Ìµ÷ÓõÄÁ½ÖÖ·½Ê½¼°±È½Ï
6.SQL´æ´¢¹ý³ÌÔÚ.NETÊý¾Ý¿âÖеÄÓ¦Óà
7.ʹÓÃSQL´æ´¢¹ý³ÌÒªÌرð×¢ÒâµÄÎÊÌâ
1.sql´æ´¢¹ý³Ì¸ÅÊö
ÔÚ´óÐÍÊý¾Ý¿âϵͳÖУ¬´æ´¢¹ý³ÌºÍ´¥·¢Æ÷¾ßÓкÜÖØÒªµÄ×÷Óá£ÎÞÂÛÊÇ´æ´¢¹ý³Ì»¹ÊÇ´¥·¢Æ÷£¬¶¼ÊÇSQL Óï¾äºÍÁ÷³Ì¿ØÖÆÓï¾äµÄ¼¯ºÏ¡£¾Í±¾ÖʶøÑÔ£¬´¥·¢Æ÷Ò²ÊÇÒ»ÖÖ´æ´¢¹ý³Ì¡£´æ´¢¹ý³ÌÔÚÔËËãʱÉú³ÉÖ´Ðз½Ê½£¬ËùÒÔ£¬ÒÔºó¶ÔÆäÔÙÔËÐÐʱÆäÖ´ÐÐËٶȺܿ졣SQL Server 2000 ²»½öÌṩÁËÓû§×Ô¶¨Òå´æ´¢¹ý³ÌµÄ¹¦ÄÜ£¬¶øÇÒÒ²ÌṩÁËÐí¶à¿É×÷Ϊ¹¤¾ßʹÓõÄϵͳ´æ´¢¹ý³Ì¡£
´æ´¢¹ý³ÌµÄ¸ÅÄî
    ´æ´¢¹ý³Ì£¨Stored Procedure£©ÊÇÒ»×éΪÁËÍê³ÉÌض¨¹¦ÄܵÄSQL Óï¾ä¼¯£¬¾­±àÒëºó´æ´¢ÔÚÊý¾Ý¿â¡£ÖÐÓû§Í¨¹ýÖ¸¶¨´æ´¢¹ý³ÌµÄÃû×Ö²¢¸ø³ö²ÎÊý£¨Èç¹û¸Ã´æ´¢¹ý³Ì´øÓвÎÊý£©À´Ö´ÐÐËü¡£
    ÔÚSQL Server µÄϵÁа汾Öд洢¹ý³Ì·ÖΪÁ½ÀࣺϵͳÌṩµÄ´æ´¢¹ý³ÌºÍÓû§×Ô¶¨Òå´æ´¢¹ý³Ì¡£ÏµÍ³¹ý³ÌÖ÷Òª´æ´¢ÔÚmaster Êý¾Ý¿âÖв¢ÒÔsp_Ϊǰ׺£¬²¢ÇÒϵͳ´æ´¢¹ý³ÌÖ÷ÒªÊÇ´Óϵͳ±íÖлñÈ¡ÐÅÏ¢£¬´Ó¶øΪϵͳ¹ÜÀíÔ± ......

MSSQLµÄ¶à²ãǶÌײéѯ

½ñÌìÔÚÁÄÌìϵͳÖÐÐèҪϵͳִÐÐÒ»¸ö¶à²ãǶÌײéѯ¡£
Ò»¿ªÊ¼Óï¾äÈçÏÂ×ܳöÏÖ´íÎó£ºÔ­À´ÊÇÔÚ]='123') ºóÎÒ¶à¼ÓÁËÒ»¸ö as tb1
¸ÄΪÈçϺó£¬ÕýÈ·ÔËÐС£
select * from ( select top(10)  * from ( select top(100)  * from (select  [chatcontent].[senderid],[chatcontent].[id] ,[chatcontent].[toid] ,[chatcontent].[sendtime] ,[chatcontent].[sendcontent]  from [chatcontent] where [chatcontent].[id] not in (select [messageid] from [messagereaded] where [messagereaded].[toid]='123') ) as tb2) as tb3) as tb4 ......

»ùÓÚmssql °ÙÍò¼¶ Êý¾Ý ²éѯ ÓÅ»¯ ¼¼ÇÉÈýÊ®Ôò

1.¶Ô²éѯ½øÐÐÓÅ»¯£¬Ó¦¾¡Á¿±ÜÃâÈ«±íɨÃ裬Ê×ÏÈÓ¦¿¼ÂÇÔÚ where ¼° order by Éæ¼°µÄÁÐÉϽ¨Á¢Ë÷Òý¡£
2.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖжÔ×ֶνøÐÐ null ÖµÅжϣ¬·ñÔò½«µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃ裬È磺
select id from t where num is null
¿ÉÒÔÔÚnumÉÏÉèÖÃĬÈÏÖµ0£¬È·±£±íÖÐnumÁÐûÓÐnullÖµ£¬È»ºóÕâÑù²éѯ£º
select id from t where num=0
3.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖÐʹÓÃ!=»ò<>²Ù×÷·û£¬·ñÔò½«ÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃè¡£
4.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖÐʹÓà or À´Á¬½ÓÌõ¼þ£¬·ñÔò½«µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃ裬È磺
select id from t where num=10 or num=20
¿ÉÒÔÕâÑù²éѯ£º
select id from t where num=10
union all
select id from t where num=20
5.in ºÍ not in Ò²ÒªÉ÷Ó㬷ñÔò»áµ¼ÖÂÈ«±íɨÃ裬È磺
select id from t where num in(1,2,3)
¶ÔÓÚÁ¬ÐøµÄÊýÖµ£¬ÄÜÓà between ¾Í²»ÒªÓà in ÁË£º
select id from t where num between 1 and 3
6.ÏÂÃæµÄ²éѯҲ½«µ¼ÖÂÈ«±íɨÃ裺
select id from t where name like '%abc%'
ÈôÒªÌá¸ßЧÂÊ£¬¿ÉÒÔ¿¼ÂÇÈ«ÎļìË÷¡£
7.Èç¹ûÔÚ where ×Ó¾äÖÐʹÓòÎÊý£¬Ò²»áµ¼ÖÂÈ«±íɨÃè¡£ÒòΪSQLÖ»ÓÐÔÚÔËÐÐʱ²Å»á½âÎ ......

MsSQL,MySQL,Oracle,Êý¾Ý¿âÁ¬½Ó×Ö¶Î

Ms sql 2000
drivername=com.microsoft.jdbc.sqlserver.SQLServerDriver
url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books
username=sa
password=sa
MySQL
drivername=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost/books
username=root
password=root
Oracle
drivername=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@localhost:1521:orcl
Username=root
Password=root
......

MsSQL,MySQL,Oracle,Êý¾Ý¿âÁ¬½Ó×Ö¶Î

Ms sql 2000
drivername=com.microsoft.jdbc.sqlserver.SQLServerDriver
url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books
username=sa
password=sa
MySQL
drivername=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost/books
username=root
password=root
Oracle
drivername=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@localhost:1521:orcl
Username=root
Password=root
......

MsSQL,MySQL,Oracle,Êý¾Ý¿âÁ¬½Ó×Ö¶Î

Ms sql 2000
drivername=com.microsoft.jdbc.sqlserver.SQLServerDriver
url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books
username=sa
password=sa
MySQL
drivername=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost/books
username=root
password=root
Oracle
drivername=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@localhost:1521:orcl
Username=root
Password=root
......

MSSQLÊý¾ÝÀàÐͼ°³¤¶ÈÏÞÖÆÏêϸ˵Ã÷

SQL Server ÌṩϵͳÊý¾ÝÀàÐͼ¯£¬¶¨ÒåÁË¿ÉÓë SQL Server Ò»ÆðʹÓõÄËùÓÐÊý¾ÝÀàÐÍ¡£ÏÂÃæÁгöϵͳÌṩµÄÊý¾ÝÀàÐͼ¯¡£
¿ÉÒÔ¶¨ÒåÓû§¶¨ÒåµÄÊý¾ÝÀàÐÍ£¬ÆäÊÇϵͳÌṩµÄÊý¾ÝÀàÐ͵ıðÃû¡£ÓйØÓû§¶¨ÒåµÄÊý¾ÝÀàÐ͵ĸü¶àÐÅÏ¢£¬Çë²Î¼û sp_addtype ºÍ´´½¨Óû§¶¨ÒåµÄÊý¾ÝÀàÐÍ¡£
µ±Á½¸ö¾ßÓв»Í¬Êý¾ÝÀàÐÍ¡¢ÅÅÐò¹æÔò¡¢¾«¶È¡¢Ð¡ÊýλÊý»ò³¤¶ÈµÄ±í´ïʽͨ¹ýÔËËã·û½øÐÐ×éºÏʱ£º
ͨ¹ý½«Êý¾ÝÀàÐ͵ÄÓÅÏÈ˳Ðò¹æÔòÓ¦Óõ½ÊäÈë±í´ïʽµÄÊý¾ÝÀàÐÍÀ´È·¶¨ËùµÃÖµµÄÊý¾ÝÀàÐÍ¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼ûÊý¾ÝÀàÐ͵ÄÓÅÏÈ˳Ðò¡£
Èç¹û½á¹ûÊý¾ÝÀàÐÍΪ char¡¢varchar¡¢text¡¢nchar¡¢nvarchar »ò ntext£¬Ôò½á¹ûÖµµÄÅÅÐò¹æÔòÓÉÅÅÐò¹æÔòµÄÓÅÏÈ˳Ðò¹æÔò¾ö¶¨¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼ûÅÅÐò¹æÔòµÄÓÅÏÈ˳Ðò¡£
½á¹ûµÄ¾«¶È¡¢Ð¡ÊýλÊý¼°³¤¶ÈÈ¡¾öÓÚÊäÈë±í´ïʽµÄ¾«¶È¡¢Ð¡ÊýλÊý¼°³¤¶È¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼û¾«¶È¡¢Ð¡ÊýλÊýºÍ³¤¶È¡£
SQL Server Ϊ SQL-92 ¼æÈÝÐÔÌṩÁËÊý¾ÝÀàÐÍͬÒå´Ê¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼ûÊý¾ÝÀàÐÍͬÒå´Ê¡£
 
 
¾«È·Êý×Ö
ÕûÊý
bigint ´Ó -2^63 (-9223372036854775808) µ½ 2^63-1 (9223372036854775807) µÄÕûÐÍÊý¾Ý£¨ËùÓÐÊý×Ö£©¡£
int ´Ó -2^31 (-2,147,483,648) µ½ 2^31 - 1 (2,147,483,64 ......

MSSQLÊý¾Ý¿âÊý¾ÝÀàÐÍ


 
    Êý¾ÝÀàÐÍ
 
 ÀàÐÍ
 
 ÃèÊö
 
bit
 
ÕûÐÍ
 
bit Êý¾ÝÀàÐÍÊÇÕûÐÍ£¬ÆäÖµÖ»ÄÜÊÇ0¡¢1»ò¿ÕÖµ¡£ÕâÖÖÊý¾ÝÀàÐÍÓÃÓÚ´æ´¢Ö»ÓÐÁ½ÖÖ¿ÉÄÜÖµµÄÊý¾Ý £¬ÈçYes »òNo¡¢True »òFa lse ¡¢On »òOff
int
 
ÕûÐÍ
 
int Êý¾ÝÀàÐÍ¿ÉÒÔ´æ´¢´Ó- 231(-2147483648)µ½231 (2147483 647)Ö®¼äµÄÕûÊý¡£´æ´¢µ½Êý ¾Ý¿âµÄ¼¸ºõËùÓÐÊýÖµÐ͵ÄÊý¾Ý¶¼¿ÉÒÔÓÃÕâÖÖÊý¾ÝÀàÐÍ¡£ÕâÖÖÊý¾ÝÀàÐÍÔÚÊý¾Ý¿âÀïÕ¼ÓÃ4¸ö ×Ö½Ú
smallint
 
ÕûÐÍ
 
smallint Êý¾ÝÀàÐÍ¿ÉÒÔ´æ´¢´Ó- 215(-32768)µ½ 215(32767)Ö®¼äµÄÕûÊý¡£ÕâÖÖÊý¾ÝÀàÐͶԴ洢һЩ³£ÏÞ¶¨ÔÚÌض¨·¶Î§ÄÚµÄÊý ÖµÐÍÊý¾Ý·Ç³£ÓÐÓá£ÕâÖÖÊý¾ÝÀàÐÍÔÚÊý¾Ý¿âÀïÕ¼ÓÃ2 ×Ö½Ú¿Õ¼ä
tinyint
 
ÕûÐÍ
 
tinyint Êý¾ÝÀàÐÍÄÜ´æ´¢´Ó0µ½255 Ö®¼äµÄÕûÊý¡£ËüÔÚÄãÖ»´òËã´æ´¢ÓÐÏÞÊýÄ¿µÄÊýÖµ ʱºÜÓÐÓᣠÕâÖÖÊý¾ÝÀàÐÍÔÚÊý¾Ý¿âÖÐÕ¼ÓÃ1 ¸ö×Ö½Ú
numeric
 
 ¾«È·Êý ÖµÐÍ
 
numericÊý¾ÝÀàÐÍÓëdecimal ÐÍÏàͬ
decimal
 
¾«È·ÊýÖµÐÍ
 
decimal Êý¾ÝÀàÐÍÄÜÓÃÀ´´æ´¢´Ó-1038-1µ½ 1038-1µÄ¹Ì¶¨¾«¶ÈºÍ·¶Î§µÄÊýÖµÐÍÊý¾Ý¡£Ê¹ÓÃÕâÖÖÊý¾ÝÀàÐÍʱ£¬±ØÐëÖ¸ ......
×ܼǼÊý:86; ×ÜÒ³Êý:15; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [1] [2] [3] 4 [5] [6] [7] [8] [9] [10]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ