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
Ïà¹ØÎĵµ£º
´ÓÕâÒ»½Ú¿ªÊ¼ÄØ£¬ÎÒÃǾÍÒª¿ªÊ¼CLRµÄ±à³ÌÖ®ÂÃÁË¡£ÔÚÕâ֮ǰ£¬ÎÒÏȰѱ¾½ÚÖÐÐèÒªÁ˽âµÄÁ½¸öÐÂÀàSqlDataRecordºÍSqlMetaData£¬¼°Îå¸öз½·¨SqlContext.Pipe.SendResultsStart£¬SqlContext.Pipe.SendResultsRow£¬SqlContext.Pipe.SendResultsEnd£¬SqlContext.Pipe.SendºÍSqlContext.Pipe.ExecuteAndSend½øÐÐһϱØÒªµÄ˵Ã÷£¬·½±ã´ ......
Sql Server ÖÐÒ»¸ö·Ç³£Ç¿´óµÄÈÕÆÚ¸ñʽ»¯º¯Êý
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06
Select CONVERT(varchar(100), GE ......
1. µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
select getdate()
2. dateadd ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
&nbs ......
SQL SelectÓï¾äÍêÕûµÄÖ´ÐÐ˳Ðò
2009-06-02 15:57
SQL SelectÓï¾äÍêÕûµÄÖ´ÐÐ˳Ðò£º1¡¢from×Ó¾ä×é×°À´×Ô²»Í¬Êý¾ÝÔ´µÄÊý¾Ý£»2¡¢where×Ó¾ä»ùÓÚÖ¸¶¨µÄÌõ¼þ¶Ô¼Ç¼ÐнøÐÐɸѡ£»3¡¢group by×Ӿ佫Êý¾Ý»®·ÖΪ¶à¸ö·Ö×飻4¡¢Ê¹Óþۼ¯º¯Êý½øÐмÆË㣻5¡¢Ê¹ÓÃhaving×Ó¾äɸѡ·Ö×飻
ÒÔϽáÂÛÊÇͨ¹ýÔÚSql Server2000ÉϵÄʵÑéµÃ³öµÄ½áÂÛ£¬ ......
1. select replace(CA_SPELL,' ','') from hy_city_area È¥³ýÁÐÖеÄËùÓпոñ
2. LTRIM£¨£© º¯Êý°Ñ×Ö·û´®Í·²¿µÄ¿Õ¸ñÈ¥µô
3. RTRIM£¨£© º¯Êý°Ñ×Ö·û´®Î²²¿µÄ¿Õ¸ñÈ¥µô
4. select LOWER(replace(CA_SPELL,' ','')) f ......