SQlÓαê
declare @CausName as char(20) declare @causenameid as int declare
@Description as varchar(200) declare @Caus_Id as int
declare @sign as char(20)
create table #tb ( Caus_Id int,CausName varchar(20),causNameid int,Caus_Description varchar(200),±êÖ¾ varchar(20))
DECLARE myCursor1 CURSOR FOR
select Caus_Id,Caus_PersonId,Caus_Description from tbObjection_Causer where Obje_Id=25
OPEN myCursor1
FETCH NEXT from myCursor1 INTO @Caus_Id,@causenameid,@Description
WHILE @@FETCH_STATUS =0
BEGIN
select @CausName=ÈËÔ±ÐÕÃû from zgong_xxi where id=@causenameid
insert into #tb
select Caus_Id=@Caus_Id,CausName=@CausName,causNameid=@causenameid,
Caus_Description=@Description,±êÖ¾=@sign where @Caus_Id is not null
FETCH NEXT from myCursor1 INTO @Caus_Id,@causenameid,@Description
END
CLOSE myCursor1
Deallocate myCursor1
select * from #tb
drop table #tb
Ïà¹ØÎĵµ£º
×ֺţº ´ó´ó ÖÐÖРСС
Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±í
SELECT * from table WITH (HOLDLOCK)
×¢Òâ: Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±íµÄÇø±ð
SELECT * from table WITH (HOLDLOCK)
ÆäËûÊÂÎñ¿ÉÒÔ¶ÁÈ¡±í£¬µ«²»ÄܸüÐÂɾ³ý
SELECT * from table WITH (TABLOCKX)
ÆäËûÊÂÎñ²»ÄܶÁÈ¡±í,¸üкÍɾ³ý
SELECT Óï¾äÖГ¼ÓË ......
ÆäʵÄã¿ÉÒÔʹÓÃÊÂÎñ´¦Àí
±È·½ËµÔÚÒ»¸ö×Ö¶ÎÀïÃæÌí¼ÓÒ»¸öboolean µÄ×ֶε±ÄãÒª´¦Àí¸Ã×ֶεÄʱºò¾Í True ÄÄô±ðµÄÈ˶¼²»¿ÉÒÔ½øÐвÙ×÷
¡¡Èç¹ûÊÇFalse ÄÄô¾Í¿ÉÒÔ½øÐвÙ×÷¡«¡«ºÇ¿É¡«¡«ÎÒÊÇÕâÑùµÄ
¡¡¡¡²»¹ýÄã¿ÉÒÔ¿´¿´¡¡
¡¡SQLËø»úÖÆ
¡¡¡¡ÒÔÏÂÊÇÎÒÕÒµÄһЩÁÏ¡¡Èç¹ûÒªÀí½âSQLËø»úÖÆ ×îºÃ°ÑÏÂÀ´¿´ÍêŶ
ĬÈϵÄÊÂÎñ¸ôÀë¼ ......
ÏÂÃæÊÇÎÒ×ܽá³öÀ´µÄÒ»¸öÊý¾Ý¿â·ÃÎʹ«¹²À࣬»ùÓÚADO.NET£¬C#µÄ£¬ÆäÖУ¬ÒÔÖØÔØµÄ·½Ê½ÊµÏÖʹÓôæÊô¹ý³ÌµÄ½Ó¿ÚºÍ²»Óô洢¹ý³ÌµÄ½Ó¿Ú£¬ÈçÓв»Í×Çë´ó¼ÒÖ¸Õý£¬Ð»Ð»~
×÷Õߣºshinehoo
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace shineh ......
SQL Server 2005 T-SQL Apply
͸¹ýÖ´Ðмƻ®¿ÉÒÔ¿´³ö£¬cross applyÀàËÆ²»´øwhereÌõ¼þµÄÁ¬½Ó¼´cross join £¨½»²æÁ¬½Ó¼´µÑ¿¨¶û»ý£º·µ»ØÐÐÊýΪ£ºÇ°±í·ûºÏÌõ¼þµÄÐгËÉϺó±í·ûºÏÌõ¼þµÄÐУ© ¡£ÐÎʽÉÏ»áÁé»îЩ.
ʹÓà APPLY ÔËËã·û¿ÉÒÔΪʵÏÖ²éѯ²Ù×÷µÄÍⲿ±í±í´ïʽ·µ»ØµÄÿ¸öÐе÷ÓñíÖµº¯Êý¡£±íÖµº¯Êý×÷ΪÓÒÊäÈ룬Íⲿ±í±í´ï ......