Çë½Ìsql¸ßÊÖ,¹ØÓÚms-sqlserverËø»úÖÆ
SQL code:
declare @cnt int
select @cnt=count(1) from TableTest
if(@cnt==0)
insert into TableTest values(1,'abc')
¶ÔÓÚÕâÑùµÄÒ»¶Îsql²¢·¢Ö´ÐÐʱ,Ó¦¸ÃÓпÉÄܲåÈëÖظ´¼Ç¼
²»ÖªµÀ´ó¼ÒÊÇÔõô·ÀÖ¹³öÏÖÖظ´Êý¾Ý,ÎÒÓÃÁË±í¼¶Ëø,¿ÉÊÇ»¹ÊdzöÏÖÁËÁ½ÌõͬÑù¼Ç¼
ÎÒÊÇÕâÑù´¦ÀíµÄ
SQL code:
declare @cnt int
begin tran
select @cnt=count(1) from TableTest with(TABLOCKX)
if(@cnt==0)
begin
insert into TableTest values(1,'abc')
commit tran
end
´òhappyflystone..³¬¼¶Ç¿ÈË..¸ú±«¶ûĬһÑùÇ¿..
Ö»ÖªµÀhappyflystone ²»ÖªµÀ±«¶ûĬ
¼Ó¸öÔ¼Êø²»¾ÍÐÐÂð
with(TABLOCKX) »áÓÐxËø£¬Ó¦¸Ã²»»áÖظ´
ѧϰ
lzµÄд·¨ÖÁÉÙÓ¦¸ÃÓиöelse rollback tran
¶¥Ò»ÏÂ~
²»Çå³þ£¬¶¥ÏÂ×Ó
ѧϰ
up
elseÎҵĴúÂëÀïÓÐ
É¢·Ö~
Ïà¹ØÎÊ´ð£º
ÎÒ°²×°SQL SERVER2008µÄʱºòÑ¡ÔñWINDOWSÉí·ÝÑéÖ¤Á¬½ÓµÄ£¬ÎÒ²»ÖªµÀÔõôдÁ¬½Ó¡£¡£¡£
»¹ÓÐÎÒÏë¸Ä³ÉSQL SERVERÉí·ÝÑéÖ¤Ôõô¸Ä£¿£¿
лл´ó¼ÒÁË£¡
XML code:
<configuration>
<appSettings>
& ......
StringBuffer str = new StringBuffer("select * from menu where parentid=1 and mid <>1 order by parentid");
List list = new ArrayList();
ResultSet rst = null;
DataBa ......
û¸É¹ýÕâÊ£¬Ò²²»ÖªµÀoracleÊý¾Ý¿âɶÑù£¬Çë½Ì´óϺÃǾßÌå²½ÖèÊÇʲô£¿ÐèҪעÒâЩʲô£¿
ÊÇÕû¸ö¿âµÄÊý¾Ý»¹ÊÇ±íµ¥?
Õæ¸öÊý¾Ý¿â
Õû¸öÊý¾Ý¿â£¬ÁíÍâÎÒÊÇ´Óһ̨װÓÐoracleµÄµçÄÔµ¼Èëµ½Áíһ̨װÓÐsql serverµÄµçÄÔÖС ......
ÓÐÁ½¸ö±í¡£·Ö±ð¶¼ÓÐIDÖ÷¼ü¡£A±íµÄIDºÍB±íµÄIDÊǶÔÓ¦µÄ£¬¾ÍÊÇA±í¼¸¸öID£¬B±í¾Í¼¸¸öID¡£A±íµÄIDÊÇʲô,B±íµÄID¾ÍÊÇʲô¡£
¿ÉÊÇÏÖÔÚA±íµÄID±ÈB±íµÄ¶àÁË¡£
ÎÒÏÖÔÚÏëÒª°ÑB±íÖÐÉٵIJ¿·Ö¸ø²¹ÆëÁË¡£Õâ¸ö²åÈëÓ¦¸ÃÔõôд ......