Sql Server2005¶Ôt sqlµÄÔöÇ¿Ö®Cross Apply
Cross Applyʹ±í¿ÉÒԺͱíÖµº¯Êý½á¹û½øÐÐjoin£¬ÔÚÏÂÃæµÄʾÀýÖн¨ÁËÁ½¸ö±íºÍÒ»¸ö±íÖµº¯Êý£¬T_bµÄÁÐa_idsÖлá´æ·Åa±íµÄidÓÃ,·Ö¸îµÄ×Ö·û´®Á¬½Ó£»ÎÒÃÇͨ¹ýcross applyʹT_a£¬T_b±íͨ¹ýsplitIDs inner join Á¬½Ó¡£Ç뿴ʾÀý£ºGO
if object_id('T_a','U') is not null
drop table T_a
GO
CREATE TABLE T_a( id int unique not null,
name varchar(50),
)
GO
if object_id('T_b',N'U') is not null
drop table T_b
GO
create table T_b
(
id int unique not null,
name varchar(10),
a_ids varchar(100) null --ÒªÔÚÕâÒ»ÁÐÖдæ·Åt_a±íµÄIDÐòÁÐ,ÕâÑù×öÁ¬µÚÒ»·¶Ê½¶¼Ã»ÓÐÂú×㣬µ«ÊÇÓÐʱºò¿¼ÂÇÐÔÄÜ»òÉè¼ÆÎÒÃÇ¿ÉÄÜ»áÏñÕâôÓÃ
)
GO
--³õʼ»¯Êý¾Ý
INSERT INTO T_a VALUES(1,'A-1')
INSERT INTO T_a VALUES(2,'A-2')
INSERT INTO T_a VALUES(3,'A-3')
INSERT INTO T_a VALUES(4,'A-4')
INSERT INTO T_a VALUES(5,'A-5')
INSERT INTO T_b VALUES(1,'B-1','1,2,4')
GO
--´´½¨Ò»¸ö±íÖµº¯Êý£¬ÓÃÀ´²ð·ÖÓöººÅ·Ö¸îµÄÊý×Ö´®£¬·µ»ØÖ»ÓÐÒ»ÁÐÊý×ֵıí
if object_id('splitIDs','TF') is not null
drop function splitIDs;
GO
create function splitIDs(
@Ids nvarchar(1000)
)
returns @t_id TABLE (id bigint)
as
begin
declare @i int,@j int,@l int,@v bigint;
set @i = 0;
set @j = 0;
set @l = len(@Ids);
while(@j < @l)
begin
set @j = charindex(',',@Ids,@i+1);
if(@j = 0) set @j = @l+1;
set @v = cast(SUBSTRING(@Ids,@i+1,@j-@i-1) as bigint);
INSERT INTO @t_id VALUES(@v)
set @i = @j;
end
return;
end
GO
--²âÊÔsplitIDsµÄÖ´ÐÐЧ¹û
select * from splitIDs('1,2,4,3')
select * from splitIDs('100')
select * from splitIDs(NULL)
GO
--ʹÓÃcross apply»ñµÃt_b±íÖÐÖ¸¶¨ÐжÔÓ¦µÄËùÓÐt_a±íÖеļǼ
select 
Ïà¹ØÎĵµ£º
ÉÏÖÜÒ»java µÄʧÀûÁË£¬ËäÈ»»¹Ã»Õýʽ¿ªÕâÃſΣ¬µ«ÎÒÒ²×ÔѧÁË°ëÄ꣬Õâ´ÎµÄʧÀûÈÃÎÒÉî¿ÌÈÏʶÁË×Ô¼ºËù´æÔڵIJ»×㡣ΪÒÔºóѧϰÁôÏÂÁ˱¦¹óµÄ¾Ñé¡£Ê컰˵£º¡°²»È뻢Ѩ£¬Ñɵû¢×Ó¡±¡£
ºóÌ죬ÎÒÒªÔÙÒ»´ÎÈ¥±±´ó¡£Õâ´Î¿¼SQL SERVER2000 £¬Í¬Ñù£¬ÕâÃÅ»¹Ã»Ñ§Í꣬Æäʵ£¬ÊǸտªÊ¼Ñ§¡£Ñ§µ½Á˵ÚÈýÕ¹ØϵģʽÉè¼ÆÔÀí £¬ ËäȻûÓбØʤµÄÐÅÐÄ ......
SQL JOIN
SQL join ÓÃÓÚ¸ù¾ÝÁ½¸ö»ò¶à¸ö±íÖеÄÁÐÖ®¼äµÄ¹Øϵ£¬´ÓÕâЩ±íÖвéѯÊý¾Ý¡£
Join ºÍ Key
ÓÐʱΪÁ˵õ½ÍêÕûµÄ½á¹û£¬ÎÒÃÇÐèÒª´ÓÁ½¸ö»ò¸ü¶àµÄ±íÖлñÈ¡½á¹û¡£ÎÒÃǾÍÐèÒªÖ´ÐÐ join¡£
Êý¾Ý¿âÖеıí¿Éͨ¹ý¼ü½«±Ë´ËÁªÏµÆðÀ´¡£Ö÷¼ü£¨Primary Key£©ÊÇÒ»¸öÁУ¬ÔÚÕâ¸öÁÐÖеÄÿһÐеÄÖµ¶¼ÊÇΨһµÄ¡£ÔÚ±íÖУ¬Ã¿¸öÖ÷¼üµÄ ......
ÎåÖÖÌá¸ß SQL ÐÔÄܵķ½·¨
ÓÐʱ£¬ ΪÁËÈÃÓ¦ÓóÌÐòÔËÐеøü¿ì£¬Ëù×öµÄÈ«²¿¹¤×÷¾ÍÊÇÔÚÕâÀï»òÄÇÀï×öһЩºÜСµ÷Õû¡£°¡£¬µ«¹Ø¼üÔÚÓÚÈ·¶¨ÈçºÎ½øÐе÷Õû£¡³ÙÔçÄú»áÓöµ½ÕâÖÖÇé¿ö£ºÓ¦ÓóÌÐòÖÐµÄ SQL ²éѯ²»ÄÜ°´ÕÕÄúÏëÒªµÄ·½Ê½½øÐÐÏìÓ¦¡£ËüҪô²»·µ»ØÊý¾Ý£¬ÒªÃ´ºÄ·ÑµÄʱ¼ä³¤µÃ³öÆæ¡£Èç¹ûËü½µµÍÁ˱¨¸æ»òÄúµÄÆóÒµÓ¦ÓóÌÐòµÄËٶȣ¬Óû§±ØÐ ......
VBͨ¹ýADOÁ¬½ÓSQL ServerÊý¾Ý¿â¿ÉÒÔ·ÖΪÓÐÔ´Êý¾Ý¿âÁ¬½ÓºÍÎÞÔ´Êý¾Ý¿âÁ¬½Ó£¬Çø±ðËüÃÇ¿´ÊÇ·ñʹÓÃÁËDSN£¨Êý¾ÝÔ´Ãû³Æ£©À´¾ö¶¨¡£
1 ÎÞÔ´Êý¾Ý¿âÁ¬½Ó
Æäʵ£¬“ÎÞÔ´Êý¾Ý¿â”Á¬½ÓÒ²²¢²»ÊÇ˵²»ÐèÒªÊý¾ÝÔ´£¬Èç¹ûûÓÐÊý¾ÝÔ´ÔòÁ¬½ÓÊÇÖ½ÉÏ̸±ø£¬Ö»ÊDz»ÐèÒªÅäÖÃODBCÊý¾ÝÔ´£¬ÀûÓÃADO¾Í¿Éͨ¹ý´úÂë½øÐÐÁ¬½Ó¡£
1.1 ADO ......
»·¾³´î½¨£º
windows MobileµÄ¿ª·¢»·¾³µÄ´î½¨(Ïêϸ˵Ã÷)
²½Öè¸ÅÊö:
1£ºPCÉϵÄSQL
SERVER
ÐèÒª¿ªÆôÔ¶³ÌÁ¬½Ó¡£
2£ºMoblieÄ£ÄâÆ÷ÐèҪͨ¹ýActiveSyncÁ¬½Ó£¬Ê¹ÆäÄܹ»Í¨¹ýPCÁ¬Íø¡£(Èç¹ûÊÇÊÖ»úµÄ»°£¬ÐèÒªÄܹ»Í¨¹ýÎÞÏßÍøÂçÁ¬È뻥ÁªÍø)
Ïêϸ˵Ã÷£º
µÚÒ»²½:SQL SERVERÒ»¶¨Òª¿ªÆôÔ¶³ÌÁ¬½Ó
1 ......