jdbcÁ¬½Ósql server
import java.sql.*;
public class JdbcUtil
{
public static void close(Statement st, Connection con)
{
try
{
st.close();
}catch(Exception e)
{
}
try
{
con.close();
}catch(Exception e)
{
}
}
public static void close(ResultSet rs, Statement st, Connection con)
{
try
{
rs.close();
}catch(Exception e)
{
}
close(st, con);
}
public static Connection getConnection() throws Exception
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
return DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db", "sa", "54321");
}
}
Ïà¹ØÎĵµ£º
SQL Server 2005£º
ALTER Table Content_Node
ADD CONSTRAINT uc_TREECODE UNIQUE (TreeCode)
ALTER TABLE Content_Node
DROP CONSTRAINT uc_TREECODE
Ô¼ÊøËùÔÚ×ֶ㤶ÈÉèΪ896£¬ÒòΪUNIQUEÔ¼ÊøµÄ×î´ó¼ü³¤¶ÈΪ 900 ×Ö½Ú£¬¶øUNIQUEÔ¼ÊøĬÈÏÕ¼ÓÐ4×Ö½Ú¡£
²Î¿¼£ºhttp://www.w3school.com.cn/sql/sql_unique.asp ......
SqlCommand com = new SqlCommand("select * from myuser where username=@UserName and password=@Pwd", con);
com.Parameters.Add(new SqlParameter("@UserN ......
ÏÈÀ´Ò»¶Î´úÂ룺
WITH OrderedOrders AS
(SELECT *,
ROW_NUMBER() OVER (order by [id])as RowNumber¡¡¡¡--idÊÇÓÃÀ´ÅÅÐòµÄÁÐ
from table_info ) --table_infoÊDZíÃû
SELECT *
from OrderedOrders
WHERE RowNumber between 50 and 60;
ÔÚwindows server 2003, sql server 2005 CTP,P4 2.66GHZ,1GB ÄÚ´æϲâÊÔ£¬Ö´ÐÐʱ ......
SQL ServerÓëExcelÊý¾Ý»¥µ¼
´ÓSQL ServerÖе¼Èë/µ¼³ö Excel µÄ»ù±¾·½·¨
/*=================== µ¼Èë/µ¼³ö Excel µÄ»ù±¾·½·¨ ===================*/
´ÓExcelÎļþÖÐ,µ¼ÈëÊý¾Ýµ½SQLÊý¾Ý¿âÖÐ,ºÜ¼òµ¥,Ö±½ÓÓÃÏÂÃæµÄÓï¾ä:
/*========================================================*/
--Èç¹û½ÓÊÜÊý¾Ýµ¼ÈëµÄ±íÒѾ´æÔÚ
ins ......
µ±ÔÚÄÚÁ¬½Ó²éѯÖмÓÈëÌõ¼þʱ£¬ÎÞÂÛÊǽ«Ëü¼ÓÈëµ½join×Ӿ䣬»¹ÊǼÓÈëµ½where×Ӿ䣬ÆäЧ¹ûÊÇÍêÈ«Ò»ÑùµÄ£¬µ«¶ÔÓÚÍâÁ¬½ÓÇé¿ö¾Í²»Í¬ÁË¡£µ±°ÑÌõ¼þ¼ÓÈëµ½ join×Ó¾äʱ£¬»á·µ»ØÍâÁ¬½Ó±íµÄÈ«²¿ÐУ¬È»ºóʹÓÃÖ¸¶¨µÄÌõ¼þ·µ»ØµÚ¶þ¸ö±íµÄÐС£Èç¹û½«Ìõ¼þ·Åµ½where×Ó¾äÖУ¬½«»áÊ×ÏȽøÐÐÁ¬½Ó²Ù×÷£¬È»ºóʹÓÃwhere×Ó¾ä¶ÔÁ¬½ÓºóµÄÐнøÐÐɸѡ¡ ......