MSSQLÊý¾Ý¿âǶÌ×´æ´¢¹ý³ÌµÄÊÂÎñ¿ØÖÆ
ÔÚMSSQL¹æ·¶ÖУ¬Ö§³ÖÊÂÎñǶÌ×£¬²»¹ýÔÚǶÌ×µ÷ÓÃ×Ó´æ´¢¹ý³Ìʱ£¬Òª»Ø¹öÊÂÎñ£¬Ðè°Ñ@@error´«¸ø×îÍâ²ãÊÂÎñ¡£¾ÙÀýÈçÏ£º
drop table testtb
go
create table testtb
(
id int,name varchar(2)
)
go
--×Ó¹ý³Ì
drop proc proc_insert_sub
go
create proc proc_insert_sub
@errResult int out--·µ»Ø´íÎóÖµ
as begin
declare @errsum int
declare @transname varchar(20)
set @transname='subtran'
set @errsum=0
--ÕýÈ·Êý¾Ý
insert testtb values(1,'00')
set @errsum=@errsum+@@error
--´íÎóÊý¾Ý
insert testtb values(2,'222')
set @errsum=@errsum+@@error
--ÕýÈ·Êý¾Ý
insert testtb values(1,'11')
set @errsum=@errsum+@@error
set @errResult=@errsum
end
go
--Ö÷¹ý³Ì
drop proc proc_insert
go
create proc proc_insert
as begin
declare @errsum int
declare @errsum1 int
set @errsum=0
set @errsum1=0
begin tran
exec proc_insert_sub @errsum1 out
print @errsum1
set @errsum=@errsum+@errsum1
print @errsum
print @@trancount
if @errsum=0
commit tran
else
ROLLBACK TRANSACTION
end
go
/*Ö´ÐÐ
exec proc_insert
select * from testtb
*/
Ïà¹ØÎĵµ£º
sql´æ´¢¹ý³Ì½Ì³Ì
[ËѼ¯ÕûÀí]sql´æ´¢¹ý³ÌÍêÈ«½Ì³Ì
Ŀ¼
1.sql´æ´¢¹ý³Ì¸ÅÊö
2.SQL´æ´¢¹ý³Ì´´½¨
3.sql´æ´¢¹ý³Ì¼°Ó¦ÓÃ
4.¸÷ÖÖ´æ´¢¹ý³ÌʹÓÃÖ¸ÄÏ
5.ASPÖд洢¹ý³Ìµ÷ÓõÄÁ½ÖÖ·½Ê½¼°±È½Ï
6.SQL´æ´¢¹ý³ÌÔÚ.NETÊý¾Ý¿âÖеÄÓ¦ÓÃ
7.ʹÓÃSQL´æ´¢¹ý³ÌÒªÌØ±ð×¢ÒâµÄÎÊÌâ
1.sql´æ´¢¹ý³Ì¸ÅÊö
ÔÚ´óÐÍÊý¾Ý¿âϵͳÖУ¬´æ´ ......
1
¡¢
MSSQL
Êý¾Ý¿âµÄ¶¨ÆÚ×Ô¶¯±¸·Ý¼Æ»®
ͨ¹ýÆóÒµ¹ÜÀíÆ÷
ÉèÖÃÊý¾Ý¿âµÄ¶¨ÆÚ×Ô¶¯±¸·Ý¼Æ»®¡£
1
¡¢´ò¿ªÆóÒµ¹Ü
ÀíÆ÷£¬Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷
2
¡¢È»ºóµãÉÏÃæ
²Ëµ¥ÖеŤ¾ß
-->
Ñ¡ÔñÊý¾Ý¿âά»¤¼Æ»®Æ÷
3
¡¢ÏÂÒ»²½Ñ¡ÔñÒª½øÐÐ×Ô¶¯±¸·ÝµÄÊý¾Ý
-->
ÏÂÒ»²½¸üÐÂÊý¾ÝÓÅ»¯ÐÅÏ¢£¬ÕâÀïÒ»°ã²»ÓÃ×öÑ¡Ôñ
-->
ÏÂÒ ......
ÏàÐźܶàASP+MSSQLµÄÍøÕ¾¶¼Óб»ÈË×¢Èë¹ýµÄ¾Àú£¬Êý¾Ý¿â±íÖжàÁËһЩ±í£¬ÀàËÆÒÔϵıíD99_tmp,D99_cmd£¬kill_kk¡£
D99_tmp£¨subdirectory,depth,fileÈý¸ö×ֶΣ¬ÀïÃæµÄÊý¾Ý¶¼ÊÇÍøÕ¾ÎļþºÍĿ¼£©
MSSQLÊý¾Ý¿â´æÔÚ¼¸¸öΣÏÕµÄÀ©Õ¹´æ´¢¹ý³Ì£¬Ä¬ÈÏPublic×é¿ÉÖ´ÐÐȨÏÞ£¬SQL×¢ÈëÕß¿ÉÀûÓô˶ÁÈ¡ÎļþĿ¼¼°Óû§×飬²¢¿Éͨ¹ýÏÈдÈëÊý¾ ......
Ëø»úÖÆ
NOLOCKºÍREADPASTµÄÇø±ð¡£
1. ¿ªÆôÒ»¸öÊÂÎñÖ´ÐвåÈëÊý¾ÝµÄ²Ù×÷¡£
BEGIN TRAN t
INSERT INTO Customer
SELECT 'a','a'
2. Ö´ÐÐÒ»Ìõ²éѯÓï¾ä¡£
SELECT * from Customer WITH (NOLOCK)
½á¹ûÖÐÏÔʾ"a"ºÍ"a"¡£µ±1ÖÐÊÂÎñ»Ø¹öºó£¬ÄÇôa½«³ÉΪÔàÊý¾Ý¡£(×¢:1ÖеÄÊÂÎñδÌá½») ¡£NOLOCK±íÃ÷ûÓжÔÊý¾Ý±íÌí¼Ó¹²Ï ......
ÈçºÎ´´½¨Á´½Ó·þÎñÆ÷
IF EXISTS (SELECT srv.name from sys.servers srv WHERE srv.server_id != 0 AND srv.name = N'Á´½Ó·þÎñÆ÷Ãû')
EXEC master.dbo.sp_dropserver @server=N'Á´½Ó·þÎñÆ÷Ãû'', @droplogins='droplogins'
GO
EXEC master.dbo.sp_addlinkedserver
@server = N'Á´½Ó·þÎñÆ÷Ãû'', @srvproduct= ......