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

sqlÓαê

ÒòΪҪ¸ù¾ÝºÜ¸´ÔӵĹæÔò´¦ÀíÓû§Êý¾Ý£¬ËùÒÔÕâÀïÓõ½Êý¾Ý¿âµÄÓαꡣƽʱ²»ÔõôÓÃÕâ¸ö£¬Ð´ÔÚÕâÀï´¿´âΪ×Ô¼º±¸¸öÍü¡£
--½«Ñ§¼®ºÅÖØ¸´µÄ·ÅÈëÁÙʱ±í tmp_zdsoft_unitive_code(³ý¸ßÖÐѧ¶ÎÍâ)
drop table tmp_zdsoft_unitive_code;
select s.id ,sch.school_code,sch.school_name,s.student_name,s.unitive_code,s.identity_card,
c.section,c.acadyear,c.class_name ,s.now_state
INTO tmp_zdsoft_unitive_code
from student_info as s ,basic_schoolinfo as sch
,basic_class as c where s.unitive_code in(
select unitive_code from student_info where len(unitive_code)>0 and isdeleted='0' group by  unitive_code having count(1)>1
) and c.section<>3 and s.isdeleted='0' and s.school_id=sch.id and s.class_id=c.id order by unitive_code,student_name
--½¨Á¢ÁÙʱ±í
drop table tmp_zdsoft_stuid;
create table tmp_zdsoft_stuid(id varchar(32) not null);
--ÀûÓÃÈý²ãÓα꣬¼ìË÷ѧ¼®ºÅÏàͬ£¬ÐÕÃûÉí·ÝÖ¤¶¼²»Í¬µÄѧÉú£¬´æ·Åµ½ÁÙʱ±ítmp_stuid
declare @unitive_code  varchar(30),
  @student_name varchar(60),
  @identity_card  varchar(18),
  @stuid  varchar(36)
--¼ìË÷ѧ¼®ºÅÖØ¸´µÄѧÉú---
declare tmp_cursor cursor for 
  select unitive_code,student_name,identity_card,id from tmp_zdsoft_unitive_code
  
OPEN tmp_cursor
FETCH next from tmp_cursor into @unitive_code,@student_name,@identity_card,@stuid
while @@fetch_status = 0
begin
 begin
 
--------------ÄÚ²ãÑ­»·£¨¼ìÑéÐÕÃûÔÚͬѧ¼®ºÅÊÇ·ñΨһ£©----------------------------
declare @count_name  int
    
declare tmp_cursor2 cursor for 
  select count(1) from tmp_zdsoft_unitive_code
  where unitive_code = @unitive_code and student_name=@student_name and (len(identity_card)=0 or isnull(identity_card,'')='')
OPEN tmp_cursor2
FETCH next from tmp_cursor2 into @count_name
while @@fetch_status = 0
begin
 begin
  if @count_name =1
  begin
   insert into tmp_zdsoft_stuid values(@s


Ïà¹ØÎĵµ£º

SQL×¢Èëʽ¹¥»÷

Ò»¡¢Ê²Ã´ÊÇSQL×¢Èëʽ¹¥»÷£¿
ËùνSQL×¢Èëʽ¹¥»÷£¬¾ÍÊǹ¥»÷Õß°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÄÊäÈëÓò»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬ÆÛÆ­·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁî¡£ÔÚijЩ±íµ¥ÖУ¬Óû§ÊäÈëµÄÄÚÈÝÖ±½ÓÓÃÀ´¹¹Ô죨»òÕßÓ°Ï죩¶¯Ì¬SQLÃüÁ»ò×÷Ϊ´æ´¢¹ý³ÌµÄÊäÈë²ÎÊý£¬ÕâÀà±íµ¥ÌرðÈÝÒ×Êܵ½SQL×¢Èëʽ¹¥»÷¡£³£¼ûµÄSQL×¢Èëʽ¹¥»÷¹ý³ÌÀàÈ磺
¢Å ......

SQL Server 2008 й¦ÄÜ

SQL Server 2008 й¦ÄÜ
 
 ÓÃÓÚ¹ÜÀíµÄй¦ÄÜÓÐÄÄЩ£¿
¶ÔÓÚ¾­³£Òª¸ºÔð¹ÜÀí·Ö²¼ÔÚÊýʮ̨ÉõÖÁÊý°Ų̀·þÎñÆ÷ÖеÄÊýÒ԰ټƻòǧ¼ÆµÄ´óÐ͸´ÔÓÊý¾Ý¿â»·¾³µÄÊý¾Ý¿â¹ÜÀíÔ±¶øÑÔ£¬ÐµIJßÂÔ¹ÜÀí¡¢¶à·þÎñÆ÷²éѯ¹¦ÄÜ¡¢ÅäÖ÷þÎñÆ÷ÒÔ¼°Êý¾ÝÊÕ¼¯Æ÷/¹ÜÀí²Ö¿â¹¦ÄÜΪËûÃǸ³ÓèÁËÇ¿´óµÄÄÜÁ¦¡£
 
 ÓÃÓÚ¿ÉÉìËõÐÔµÄй¦ÄÜÓÐÄ ......

sqlº¯Êý³£Óú¯Êý

1.     select replace(CA_SPELL,' ','') from hy_city_area  È¥³ýÁÐÖеÄËùÓпոñ
2.     LTRIM£¨£© º¯Êý°Ñ×Ö·û´®Í·²¿µÄ¿Õ¸ñÈ¥µô
3.     RTRIM£¨£© º¯Êý°Ñ×Ö·û´®Î²²¿µÄ¿Õ¸ñÈ¥µô
4.     select LOWER(replace(CA_SPELL,' ','')) f ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ