sqlserverÑ»·Éú³ÉÊý¾Ý - MS-SQL Server / »ù´¡Àà
ÏÖÔÚÓÐÒ»¸ö±ítable1£¬Ö»ÓÐÒ»¸ö×ֶΣ¬varchar£¨10£©
num
111
112
113
114
ÏÖÔÚÏëҪѻ·table1ÖеÄËùÓÐÊý¾Ý£¬ÔÀ´µÄ111Éú³É111001-111999²åÈëµ½table2ÖÐ
SQL code:
Select ltrim([num])+right(1000+number,3)col
from tb a,master..spt_values b
where type='P' and number between 1 and 999
sqlÖеÄÑ»·ÒªÓÃÓα꣬ÏÈÕ¼¸ösf
SQL code:
if not object_id('tb') is null
drop table tb
Go
Create table tb([num] int)
Insert tb
select 111 union all
select 112 union all
select 113 union all
select 114
Go
Select ltrim([num])+right(1000+number,3)col
from tb a,master..spt_values b
where type='P' and number between 1 and 999
/*
col
------------------
111001
112001
113001
114001
111002
112002
113002
114002
111003
112003
113003
114003
111004
112004
113004
114004
111005
112005
113005
114005
111006
112006
113006
114006
111007
112007
113007
114007
111008
112008
113008
114008
111009
112009
113009
114009
111010
112010
113010
114010
111011
112011
113011
114011
111012
112012
113012
114012
111013
112013
113013
114013
111014
112014
113014
114014
111015
112015
113015
114015
111016
112016
113016
114016
111017
112017
113017
114017
111018
112018
113018
11
Ïà¹ØÎÊ´ð£º
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
ÐèÇóÈçÏ£º
ѧԺ academy£¨aid,aname£©
°à¼¶ class£¨cid,cname,aid£©
ѧÉú stu(sid,sname,aid,cid)
סËÞÇø region(rid,rname)
ËÞÉáÂ¥ build(bid,rid,bnote) bnoteÊÇ¡®ÄС¯/¡®Å®¡¯
ËÞÉá dorm(did,rid,bid£¬bedn ......
select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
ÎҸоõûÓÐÇø±ð°¡£¬ÔõôÔÚmysql»áÓÐ ......
SQL code:
rs.open "select * from guide where city_name='±±¾©' order by pai desc",conn,1,1
do while not rs.eof or rs.bof
¡£¡£
¡£¡£
¡£¡£
rs.movenext
loop
Õâ¸ösqlÓï¾äÔÚwapÕ¾Àï ±¾ÉíÓÐ ......
Ö´ÐÐÊý¾Ý¿â²Ù×÷ʱ£¬Ö±½ÓÓÃSQL Óï¾äºÃһЩ »¹ÊÇÓô洢¹ý³Ì¸ü¼ÑÄØ£¿
¸÷ÊãÆð¼û
Õâ¸öµÄ¾ßÌåÎÊÌâ¾ßÌå·ÖÎö
¼òµ¥µÄselect ¡¢updateºÍinsertµ±È»sql½â¾öÁË
¸´ÔӵķÅÔÚsql·þÎñ¶ËÓ¦¸ÃºÃµã
Â¥Ö÷Çë²ÎÔÄ
http://msdn.micr ......