Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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
 ×îÐÂÎÄÕ : sql

asp·ÀSQL×¢È뺯Êý


'SQL·À×¢È뺯Êý£¬µ÷Ó÷½·¨£¬ÔÚÐèÒª·À×¢ÈëµÄµØ·½Ìæ»»ÒÔÇ°µÄrequest("XXXX")ΪSafeRequest("XXXX")
  
'www.yongfa365.com
  
  
Function
 SafeRequest(ParaValue)   
    ParaValue = 
Trim
(
Request
(ParaValue))   
    
If
 ParaValue = 
""
 
Then
  
        SafeRequest = 
""
  
        
Exit
 
Function
  
    
End
 
If
  
    
'Òª¹ýÂ˵Ä×Ö·ûÒÔ","¸ô¿ª
  
    LockValue = 
"',Select,Update,Delete,insert,Count(,drop table,truncate,Asc(,Mid(,char(,xp_cmdshell,exec master,net localgroup administrators,And,net user,Or"
  
 &nb ......

asp·ÀSQL×¢È뺯Êý


'SQL·À×¢È뺯Êý£¬µ÷Ó÷½·¨£¬ÔÚÐèÒª·À×¢ÈëµÄµØ·½Ìæ»»ÒÔÇ°µÄrequest("XXXX")ΪSafeRequest("XXXX")
  
'www.yongfa365.com
  
  
Function
 SafeRequest(ParaValue)   
    ParaValue = 
Trim
(
Request
(ParaValue))   
    
If
 ParaValue = 
""
 
Then
  
        SafeRequest = 
""
  
        
Exit
 
Function
  
    
End
 
If
  
    
'Òª¹ýÂ˵Ä×Ö·ûÒÔ","¸ô¿ª
  
    LockValue = 
"',Select,Update,Delete,insert,Count(,drop table,truncate,Asc(,Mid(,char(,xp_cmdshell,exec master,net localgroup administrators,And,net user,Or"
  
 &nb ......

ÈýÖÖSQL·ÖÒ³Óï¾ä

À´×Ô£ºhttp://www.cnblogs.com/morningwang/archive/2009/01/02/1367277.html
ÓйطÖÒ³ SQL µÄ×ÊÁϺܶ࣬ÓеÄʹÓô洢¹ý³Ì£¬ÓеÄʹÓÃÓαꡣ±¾È˲»Ï²»¶Ê¹ÓÃÓα꣬ÎÒ¾õµÃËüºÄ×Ê¡¢Ð§Âʵͣ»Ê¹Óô洢¹ý³ÌÊǸö²»´íµÄÑ¡Ôñ£¬ÒòΪ´æ´¢¹ý³ÌÊǾ­¹ýÔ¤±àÒëµÄ£¬Ö´ÐÐЧÂʸߣ¬Ò²¸üÁé»î¡£ÏÈ¿´¿´µ¥Ìõ SQL Óï¾äµÄ·ÖÒ³ SQL °É¡£
·½·¨1£º
ÊÊÓÃÓÚ SQL Server 2000/2005
SELECT TOP Ò³´óС *
from table1
WHERE id NOT IN
(
SELECT TOP Ò³´óС*(Ò³Êý-1) id from table1 ORDER BY id
)
ORDER BY id 
·½·¨2£º
ÊÊÓÃÓÚ SQL Server 2000/2005
SELECT TOP Ò³´óС *
from table1
WHERE id >
(
SELECT ISNULL(MAX(id),0)
from
(
SELECT TOP Ò³´óС*(Ò³Êý-1) id from table1 ORDER BY id
) A
)
ORDER BY id 
·½·¨3£º
ÊÊÓÃÓÚ SQL Server 2005
SELECT TOP Ò³´óС *
from
(
SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* from table1
) A
WHERE RowNumber > Ò³´óС*(Ò³Êý-1) 
˵Ã÷£¬Ò³´óС ......

¿ìËٸ㶨ÔÚEclipseÖÐÓÃJDBCÁ¬½ÓSQL Server 2005

1¡¢ÏÂÔرر¸Èí¼þ
(1) JDK (Java Development Kit)
SUN¹Ù·½µÄÏÂÔصØÖ·ÊÇhttp://java.sun.com/javase/downloads/index.jsp
(2) JDBC
(3) Eclipse
(4) Microsoft SQL Server 2005 Express£¨µ±È»£¬ÓзÇExpressÒ²OK°¡£©
(5) SQL Server Management Studio
2¡¢°²×°Óë»·¾³ÅäÖÃ
(1) JDK
Ê×ÏÈÔÚWindows»·¾³Ï£¬ÏÂÔغó°²×°¼´¿É¡£
È»ºóÔÚÎҵĵçÄÔ-ÊôÐÔ-¸ß¼¶ÏµÍ³ÉèÖÃ-¸ß¼¶-»·¾³±äÁ¿-ϵͳ±äÁ¿£º
1¡¢“н¨”£º±äÁ¿ÃûΪJAVA_HOME£¬±äÁ¿ÖµÎªJDKµÄ¸ùĿ¼¡£
2¡¢“н¨”£º±äÁ¿ÃûΪCLASSPATH£¬±äÁ¿ÖµÎª%JAVA_HOME%\lib
3¡¢“н¨”£º±äÁ¿ÃûΪPATH£¬±äÁ¿ÖµÎª%JAVA_HOME%\bin
×¢Ò⣺Èç¹û±äÁ¿ÃûÒѾ­´æÔÚ£¬ÔòÑ¡Ôñ“±à¼­”£¬ÔÚ±äÁ¿ÖµµÄ×îºó¼ÓÉÏ“;”£¨·ÖºÅ£©£¬²¢ÔڷֺźóÃæÊäÈëÉÏÃæËùÊöµÄ±äÁ¿Öµ¡£
×îºó±ðÍüÁ˵ã“È·¶¨”¡£ÏÖÔھͿÉÒÔÔÚÃüÁîÐÐÖÐʹÓÓjavac”ÁË¡£
(2) JDBC
ÏÂÔغó½âѹ£¬ÔÚ°²×°Ä¿Â¼ÕÒµ½sqljdbc.jar£¨×¢Ò⣬Ä㻹»áÕÒµ½Ò»¸ösqljdbc4.jar£¬¿¼Âǵ½ÓеÄjre°æ±¾µÍµÄÇé¿ö£¬Ö»ÓÃsqljdbc.jar£¬²»ÓÃsqljdbc4.jar£©¡£
¼ÆËã»ú->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿->ϵͳ±äÁ¿->classpath×îºó×·¼ÓÕ⸠......

sqlÈÕÆÚº¯Êý

SQLServerʱ¼äÈÕÆÚº¯ÊýÏê½â,SQLServer,ʱ¼äÈÕÆÚ,
1.      µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
        select getdate()
2. dateadd      ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
       ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
       select dateadd(day,2,'2004-10-15')      --·µ»Ø£º2004-10-17 00:00:00.000
3. datediff ·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£
       select datediff(day,'2004-09-01','2004-09-18')       --·µ»Ø£º17
       select datediff(day,'2004-09-18','2004-09-01')       --·µ»Ø£º-17
4. datepart ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊý¡£
      SELECT DATEPART(month, '2004-10-15')      --·µ»Ø 10
5. datename ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®
  &nbs ......

Sql Server»ù±¾º¯Êý

1.×Ö·û´®º¯Êý
³¤¶ÈÓë·ÖÎöÓÃ
datalength(Char_expr) ·µ»Ø×Ö·û´®°üº¬×Ö·ûÊý,µ«²»°üº¬ºóÃæµÄ¿Õ¸ñ
substring(expression,start,length) ²»¶à˵ÁË,È¡×Ó´®
right(char_expr,int_expr) ·µ»Ø×Ö·û´®ÓÒ±ßint_expr¸ö×Ö·û
×Ö·û²Ù×÷Àà
upper(char_expr) תΪ´óд
lower(char_expr) תΪСд
space(int_expr) Éú³Éint_expr¸ö¿Õ¸ñ
replicate(char_expr,int_expr)¸´ÖÆ×Ö·û´®int_expr´Î
reverse(char_expr) ·´×ª×Ö·û´®
stuff(char_expr1,start,length,char_expr2) ½«×Ö·û´®char_expr1ÖеĴÓ
start¿ªÊ¼µÄlength¸ö×Ö·ûÓÃchar_expr2´úÌæ
ltrim(char_expr) rtrim(char_expr) È¡µô¿Õ¸ñ
ascii(char) char(ascii) Á½º¯Êý¶ÔÓ¦,È¡asciiÂë,¸ù¾ÝasciiÂðÈ¡×Ö·û
×Ö·û´®²éÕÒ
charindex(char_expr,expression) ·µ»Øchar_exprµÄÆðʼλÖÃ
patindex("%pattern%",expression) ·µ»ØÖ¸¶¨Ä£Ê½µÄÆðʼλÖÃ,·ñÔòΪ0
2.Êýѧº¯Êý
abs(numeric_expr) Çó¾ø¶ÔÖµ
ceiling(numeric_expr) È¡´óÓÚµÈÓÚÖ¸¶¨ÖµµÄ×îСÕûÊý
exp(float_expr) È¡Ö¸Êý
floor(numeric_expr) СÓÚµÈÓÚÖ¸¶¨ÖµµÃ×î´óÕûÊý
pi() 3.1415926.........
power(numeric_expr,power) ·µ»Øpower´Î·½
rand([int_expr]) Ëæ»úÊý²úÉúÆ÷
round(nu ......

SQL Server 2005 Driver for JDBC


Load the SQL Server 2005 Driver for JDBC before you load the SQL Server 2000 Driver for JDBC. To do this, use the DriverManager class as in the following code example.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // 2005 version
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); // 2000 version
Use a SQL Server 2005 Driver for JDBC connection URL to establish a connection. To do this, use code that resembles the following code example.
Connection con = DriverManager.getConnection("jdbc:sqlserver://<ServerName>;user=<UserName>;password=<Password>");
For more information about how to connect with data sources and how to use a connection URL, visit the following Microsoft Developer Network (MSDN) Web sites:
Building the connection URL
http://msdn2.microsoft.com/en-us/library/ms378428.aspx (http://msdn2.microsoft.com/en-us/library/ms378428.aspx)
Setting the connection properties
http://msdn2.microsoft.com/en-us/library/ms378988.as ......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [5] [6] [7] [8] 9 [10] [11] [12] [13] [14]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ