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

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
*/


Ïà¹ØÎĵµ£º

mssql´æ´¢¹ý³ÌÊÕ¼¯


sql´æ´¢¹ý³Ì½Ì³Ì
[ËѼ¯ÕûÀí]sql´æ´¢¹ý³ÌÍêÈ«½Ì³Ì 
Ŀ¼
1.sql´æ´¢¹ý³Ì¸ÅÊö
2.SQL´æ´¢¹ý³Ì´´½¨
3.sql´æ´¢¹ý³Ì¼°Ó¦ÓÃ
4.¸÷ÖÖ´æ´¢¹ý³ÌʹÓÃÖ¸ÄÏ
5.ASPÖд洢¹ý³Ìµ÷ÓõÄÁ½ÖÖ·½Ê½¼°±È½Ï
6.SQL´æ´¢¹ý³ÌÔÚ.NETÊý¾Ý¿âÖеÄÓ¦Óà
7.ʹÓÃSQL´æ´¢¹ý³ÌÒªÌØ±ð×¢ÒâµÄÎÊÌâ
1.sql´æ´¢¹ý³Ì¸ÅÊö
ÔÚ´óÐÍÊý¾Ý¿âϵͳÖУ¬´æ´ ......

MSSQLÊý¾Ý¿â±¸·Ý

1
¡¢
MSSQL
Êý¾Ý¿âµÄ¶¨ÆÚ×Ô¶¯±¸·Ý¼Æ»®
 
ͨ¹ýÆóÒµ¹ÜÀíÆ÷
ÉèÖÃÊý¾Ý¿âµÄ¶¨ÆÚ×Ô¶¯±¸·Ý¼Æ»®¡£
1
¡¢´ò¿ªÆóÒµ¹Ü
ÀíÆ÷£¬Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷
2
¡¢È»ºóµãÉÏÃæ
²Ëµ¥ÖеŤ¾ß
-->
Ñ¡ÔñÊý¾Ý¿âά»¤¼Æ»®Æ÷
3
¡¢ÏÂÒ»²½Ñ¡ÔñÒª½øÐÐ×Ô¶¯±¸·ÝµÄÊý¾Ý
-->
ÏÂÒ»²½¸üÐÂÊý¾ÝÓÅ»¯ÐÅÏ¢£¬ÕâÀïÒ»°ã²»ÓÃ×öÑ¡Ôñ
-->
ÏÂÒ ......

MSSQLÊý¾Ý¿âÖз¢ÏÖD99_tmp±íµÄ´¦Àí·½·¨

ÏàÐźܶàASP+MSSQLµÄÍøÕ¾¶¼Óб»ÈË×¢Èë¹ýµÄ¾­Àú£¬Êý¾Ý¿â±íÖжàÁËһЩ±í£¬ÀàËÆÒÔϵıíD99_tmp,D99_cmd£¬kill_kk¡£
D99_tmp£¨subdirectory,depth,fileÈý¸ö×ֶΣ¬ÀïÃæµÄÊý¾Ý¶¼ÊÇÍøÕ¾ÎļþºÍĿ¼£©
MSSQLÊý¾Ý¿â´æÔÚ¼¸¸öΣÏÕµÄÀ©Õ¹´æ´¢¹ý³Ì£¬Ä¬ÈÏPublic×é¿ÉÖ´ÐÐȨÏÞ£¬SQL×¢ÈëÕß¿ÉÀûÓô˶ÁÈ¡ÎļþĿ¼¼°Óû§×飬²¢¿Éͨ¹ýÏÈдÈëÊý¾ ......

½²½âMSSQLÊý¾Ý¿âÖÐ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±íÃ÷ûÓжÔÊý¾Ý±íÌí¼Ó¹²Ï ......

ÆôÓÃMSSQL·Ö²¼Ê½ÊÂÎñµÄ³£¼ûÎÊÌâ

ÈçºÎ´´½¨Á´½Ó·þÎñÆ÷
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= ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ