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

ÁÙʱ±ívs.±í±äÁ¿ÒÔ¼°ËüÃǶÔSQLServerÐÔÄܵÄÓ°Ïì

ÔÚÁÙʱ±í
create table #T (…)
ºÍ±í±äÁ¿
declare @T table (…)
Ö®¼äÖ÷ÒªÓÐ3¸öÀíÂÛÉϵIJ»Í¬¡£
µÚÒ»¸ö²»Í¬Ê¹ÊÂÎñÈÕÖ¾²»»á¼Ç¼±í±äÁ¿¡£Òò´Ë£¬ËüÃÇÍÑÀëÁËÊÂÎñ»úÖƵķ¶Î§£¬´ÓÏÂÃæµÄÀý×Ó¿ÉÏÔ¶øÒ×¼û£º
create table #T (s varchar(128))
declare @T table (s varchar(128))
insert into #T select 'old value #'
insert into @T select 'old value @'
begin transaction
    update #T set s='new value #'
    update @T set s='new value @'
rollback transaction
select * from #T
select * from @T
s
---------------
old value #
s
---------------
new value @
ÔÚÉùÃ÷ÁÙʱ±í#TºÍ±í±äÁ¿@TÖ®ºó£¬¸øËüÃÇ·ÖÅäÒ»¸öÏàͬµÄֵΪold value×Ö·û´®¡£È»ºó£¬¿ªÊ¼Ò»¸öÊÂÎñÈ¥¸üÐÂËüÃÇ¡£´Ëʱ£¬ËüÃǶ¼½«ÓÐеÄÏàͬµÄÖµnew value×Ö·û´®¡£µ«µ±ÊÂÎñ»Ø¹öʱ£¬ÕýÈçÄãËù¿´µ½µÄ£¬±í±äÁ¿@T±£ÁôÁËÕâ¸öÐÂÖµ¶øûÓзµ»Øold value×Ö·û´®¡£ÕâÊÇÒòΪ¼´Ê¹±í±äÁ¿ÔÚÊÂÎñÄÚ±»¸üÐÂÁË£¬Ëü±¾Éí²»ÊÇÊÂÎñµÄÒ»²¿·Ö¡£
µÚ¶þ¸öÖ÷ÒªµÄ²»Í¬ÊÇÈκÎÒ»¸öʹÓÃÁÙʱ±íµÄ´æ´¢¹ý³Ì¶¼²»»á±»Ô¤±àÒ룬Ȼ¶øʹÓñí±äÁ¿µÄ´æ´¢¹ý³ÌµÄÖ´Ðмƻ®¿ÉÒÔÔ¤ÏȾ²Ì¬µÄ±àÒë¡£Ô¤±àÒëÒ»¸ö½Å±¾µÄÖ÷ÒªºÃ´¦ÔÚÓÚ¼Ó¿ìÁËÖ´ÐеÄËٶȡ£Õâ¸öºÃ´¦¶ÔÓÚ³¤µÄ´æ´¢¹ý³Ì¸ü¼ÓÏÔÖø£¬ÒòΪ¶ÔËüÀ´ËµÖØбàÒë´ú¼ÛÌ«¸ß¡£
×îºó£¬±í±äÁ¿½ö´æÔÚÓÚÄÇЩ±äÁ¿ÄÜ´æÔÚµÄÏàͬ·¶Î§ÄÚ¡£ºÍÁÙʱ±íÏà·´£¬ËüÃÇÔÚÄÚ²¿´æ´¢¹ý³ÌºÍexec£¨string£©Óï¾äÀïÊDz»¿É¼ûµÄ¡£ËüÃÇÒ²²»ÄÜÔÚinsert/execÓï¾äÀïʹÓá£
ÐÔÄܱȽÏ
Ê×ÏÈ£¬×¼±¸Ò»¸öÓÐ100Íò¼Ç¼µÄ²âÊÔ±í£º
create table NUM (n int primary key, s varchar(128))
GO
set nocount on
declare @n int
set @n=1000000
while @n>0 begin
    insert into NUM
          select @n,'Value: '+convert(varchar,@n)
    set @n=@n-1
    end
GO
×¼±¸²âÊÔ´æ´¢¹ý³ÌT1£º
create procedure T1
    @total int
as
    create table #T (n int, s varchar(128))
    insert into #T select n,s from NUM
          where n%100>0 and n<=@total
    declare @res varchar(128)
    select @res=max(s) from NUM
          where n<=@total and


Ïà¹ØÎĵµ£º

ʹÓÃÁÙʱ±íÌáÉýSqlServerÊÓͼ²éѯÐÔÄÜ

дÁËÒ»¸ö´æ´¢¹ý³Ì¶ÔÊÓͼ½øÐзÖÒ³²éѯ£¬µ«Êý¾ÝÔö¶àºó·¢ÏÖ»ùЧÂʵ͵ÃÒªÃü£¬ÈýÍò¶àÌõÊý¾ÝÒª²éѯһ¸ö°ëСʱ¶¼Ã»³öÀ´£¬Õâ²»ÊÇÒªÁËÃü£¬ÓÚÊÇÏëµ½ÁËË÷Òý£¬Ó¦ÓùýºóÈÔÎÞ¼ÃÓÚÊ¡£×îºó¶Ôsql½øÐзÖÎöºÍʵ¼ùÖеóö£¬Ê¹ÓÃÁÙʱ±í¿ÉÒÔ´ó´ó¼Ó¿ìÊÓͼµÄ²éѯËٶȣ¬¼ûÈçÏÂsqlÓï¾ä
ÐÔÄܳ¬µÍµÄÊÓͼ·ÖÒ³sqlÓï¾ä£º
select top 100 * from
view_c ......

JavaScript ºÍJSP Á¬½ÓSqlServer Êý¾Ý¿â

µÚÒ»ÖÖ JavaScriptÁ¬½ÓÊý¾Ý¿â£º
<mce:script language="JavaScript"><!--
// ´´½¨Êý¾Ý¿â¶ÔÏó
var objdbConn = new ActiveXObject("ADODB.Connection");
// DSN×Ö·û´®
var strdsn = "Driver={SQL Server};SERVER=192.168.0.210;UID=xhb;PWD=xhb;DATABASE=books";
// ´ò¿ªÊý¾ÝÔ´
objdbConn.Open(strdsn);
// ......

JavaScriptÁ¬½ÓSqlServer²¢ÊµÏÖ·ÖÒ³(¶þ)

//×ܼǼÊý
function sumRecord()
{
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "select count(*) as RecordCount from baoming";
rs.open(sql, ......

Çå³ýSQLServerÊý¾Ý¿âÈÕÖ¾(SqlServer2005)

ÔÚÖ÷Êý¾Ý¿âÎļþ½øÐдóÁ¿µÄɾ³ý(ÐÂÔö£¬Ð޸Ķ¼»áÓÐÈÕÖ¾)£¬ÈÕÖ¾ÎļþÓÐ1.5G¡£×òÌ컹ԭÊý¾Ý¿âʱ³õʼֵҲ²Å1MB¡£±ØÐëÇå³ýµô£¬²»È»Ì«Õ¼¿Õ¼äÁË¡£ÉÏÍøÕÒÁ˸öÇå³ýÈÕÖ¾µÄ·½·¨¡£Ë³Àû½«ÈÕÖ¾Îļþlog.ldf´Ó1.5G±äΪÁË1M¡£ ÎÒÖ´ÐÐÈçÏ£º
 1.Çå¿ÕÈÕÖ¾
 DUMP TRANSACTION ¿âÃû WITH NO_LOG
2.½Ø¶ÏÊÂÎñÈÕÖ¾£º
 BACKUP LOG ......

SqlServerÃüÃû¹æ·¶

ÃüÃû¹ý³ÌÖÐÈçÓÐÏÖ´æµÄËõд£¬ÔòʹÓøÃËõд£¬ÈçÎÞ£¬Ò»Âɲ»µÃËõд£¬Àý£ºISBN
Êý¾Ý¿â£ºÓÃÒ»¸ö»òÈý¸öÒÔÏÂÓ¢Îĵ¥´Ê×é³É£¬µ¥´ÊÊ××Öĸ´óд£¬È磺DepartmentManage£»
±íÃû£ºÊ¹ÓÃÃû´ÊÐÔÖʵĵ¥´ÊÈ«Æ´±íʾ£¬¸÷µ¥´ÊÊ××Öĸ´óд£¬ ʹÓø´ÊýÐÎʽ£¬È磺Books
      Èç¹û¸Ã±íÓÃÓÚ±íÃ÷ÁíÍâÁ½±íÖÐ×ֶμäµÄ¹Øϵ£¬Óõ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ