ASPÖÐʹÓÃSQLServerµÄÊÂÎñ¿ØÖƼ°ÅúÖ´ÐÐSqlÓï¾ä
<%
SQL1 = "update table1 set a=b where id=1"
Conn.ExeCute SQL1
SQL2 = "update table2 set a=b where id=2"
Conn.ExeCute SQL2
SQL3 = "update table3 set a=b where id=3"
Conn.ExeCute SQL3
%>
ÊÂʵÉÏ£¬ÕâÊÇÒ»ÖÖЧÂʺܵÍϵÄд·¨£¬ÎªÁËÌá¸ßSQLµÄÖ´ÐÐЧÂÊ£¬ÎÒÃÇ¿ÉÒ԰Ѷà¸öSQLÓï¾äÓ÷ֺÅÆ´½ÓÔÚÒ»Æð£¬È»ºóÒ»´ÎÐÔ½»¸øConnÀ´Ö´ÐС£ÈçÏ£º
<%
SQL1 = "update table1 set a=b where id=1"
SQL2 = "update table2 set a=b where id=2"
SQL3 = "update table3 set a=b where id=3"
SQL = SQL1 & ";" & SQL2 & ";" & SQL3
Conn.ExeCute SQL
%>
µ«ÊÇ£¬ÒÔÉÏ2ÖÖд·¨¶¼»áÃæÁÙÒ»¸öÎÊÌ⣬¾ÍÊǵ±ÎÒÃÇÐèÒª±£Ö¤3ÌõSQLÓï¾ä¶¼±ØÐëÍêÕûÖ´ÐУ¬µ±Ä³Ò»ÌõÖ´ÐдíÎóʱ£¬ÆäËû2ÌõÒ²¸úׯعöʱ£¬ÎÒÃǾÍÐèÒªÓõ½SQLServerµÄÊÂÎñ¿ØÖÆÁË£¬²»ÉÙµÄÎÄÕ½¨ÒéʹÓÃÒÔÏ·½·¨£º
<%
dim Conn=Server.CreateObject("ADODB.Connection")
'¿ªÊ¼ÊÂÎñ
Conn.BeginTrans
'Ö´ÐÐSQL,Èô³É¹¦ÔòÌύʣ¬·ñÔò»Ø¹öÊÂÎñ
Conn.Execute(sqlÓï¾ä)
'Ìá½»ÊÂÎñ
Conn.CommitTrans
'»Ø¹öÊÂÎñ
Conn.RollbackTrans
%>
Ôںܶàʱºò£¬Õâ²¢²»ÄÜ´ïµ½±£Ö¤SQLÓï¾äÍêÕûÖ´ÐеÄÄ¿µÄ£¬¸ßЧµÄ×ö·¨Ó¦¸ÃÊÇÀûÓÃSQLServer±¾ÉíµÄÊÂÎñ¿ØÖƹ¦ÄÜ£¬ÈçÏ£º
<%
Sub ExeSql(byval SqlStr)
Dim TrSql
TrSql = "SET XACT_ABORT ON;BEGIN TRANSACTION;"
TrSql = TrSql & SqlStr
TrSql = TrSql & ";COMMIT TRANSACTION;SET XACT_ABORT OFF"
Conn.ExeCute(TrSql)
End Sub
SQL1 = "update table1 set a=b where id=1"
SQL2 = "update table2 set a=b where id=2"
SQL3 = "update table3 set a=b where id=3"
SQL = SQL1 & ";" & SQL2 & ";" & SQL3
ExeSql SQL
%>
Ïà¹ØÎĵµ£º
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......
ÎÒÔÚ°ÑoracleÊý¾Ýµ¼ÈësqlserverÖÐʱ£¬·¢ÏÖÔÚoracleÖÐ×ֶζ¨ÒåΪΨһË÷Òýʱ£¬²»Í¬¼Ç¼µÄ´Ë×Ö¶ÎÈç¹ûΪ¿Õ²»±»ÈÏΪÊÇÖظ´µÄ£¬µ«ÔÚsqlserverÖÐÈç¹û´Ë×Ö¶ÎΪΨһË÷Òý×ֶΣ¬²»ÔÊÐíÓÐ2¸öÒÔÉϵĿÕÖµ¡£ÓôÃÆ¡£ËùÒÔÖ»ºÃ½«sqlserverÖеÄΨһË÷Òý×Ö¶ÎÊÖ¹¤ÐÞ¸ÄΪ¼¸¸ö·Ç¿ÕµÄÖµ£¬µ«ÕâÑù³ÌÐò¿Ï¶¨Òª½øÐÐÐÞ¸ÄÁË¡£ÐèÒªÔÚ³ÌÐòÖÐΪ´Ë×Ö¶ÎÉèÖò»Öظ´ ......
SQLSERVER ´óÊý¾ÝÁ¿²åÈëÃüÁ
BULK INSERTÊÇSQLSERVERÖÐÌṩµÄÒ»Ìõ´óÊý¾ÝÁ¿µ¼ÈëµÄÃüÁËüÔËÓÃDTS(SSIS)µ¼ÈëÔÀí£¬¿ÉÒÔ´Ó±¾µØ»òÔ¶³Ì·þÎñÆ÷ÉÏÅúÁ¿µ¼ÈëÊý¾Ý¿â»òÎļþÊý¾Ý¡£ÅúÁ¿²åÈëÊÇÒ»¸ö¶ÀÁ¢µÄ²Ù×÷£¬ÓŵãÊÇЧÂʷdz£¸ß¡£È±µãÊdzöÏÖÎÊÌâºó²»¿ÉÒԻعö¡£
¡¡¡¡BULK INSERTÊÇÓÃÀ´½«ÍⲿÎļþÒÔÒ»ÖÖÌض¨µÄ¸ñʽ¼ÓÔ ......
=================·ÖÒ³==========================
/*·ÖÒ³²éÕÒÊý¾Ý*/
CREATE PROCEDURE [dbo].[GetRecordSet]
@strSql varchar(8000),--²éѯsql,Èçselect * from [user]
@PageIndex int,--²éѯµ±Ò³ºÅ
@PageSize int--ÿҳÏÔʾ¼Ç¼
AS
set nocount on
declare @p1 int
declare @current ......
EXEC sp_addlinkedsrvlogin @rmtsrvname = 'serverontest', @useself = 'false', @locallogin = 'sa', @rmtuser = 'sa', @rmtpassword = 'passwordofsa'
Ìí¼ÓµÇ¼·½Ê½
ÒÔÉÏÁ½¸öÓï¾äÖУ¬@serverΪ·þÎñÆ÷µÄ±ðÃû£¬@datasrcΪҪÁ´½ÓµÄÄ¿±êÊý¾Ý¿âµÄÁ¬½Ó´®£¬@rmtsrvnameΪ±ðÃû,@localloginΪ±¾µØµÇ¼µÄÓû§Ãû£¬@rmtuserºÍ@rmtpa ......