ÏÖÔÚÓÐÒ»ÕűíA ÓÐÈýÁÐ c1,c2,c3 £¬Ö»ÓÐÒ»Ìõ¼Ç¼,Öµ·Ö±ðΪv1,v2,v3
A:
c1 c2 c3
v1 v2 v3
Òª°ÑËüת³ÉÁÙʱ±í#t Ö»ÓÐÁ½ÁÐm,n£¬ÆäÖÐmÁзÅA±íµÄÁÐ±í£¬nÁзÅA±íµÄÁжÔÓ¦µÄÖµ
#t
m n
c1 v1
c2 v2
c3 v3
ÇëÎÊÔõôת»»£¬Çë¸ßÊÖ¸ø³öÓï¾ä£¬¼±¡£¡£¡£¡£
SQL code:
select c1 as m,v1 as n from a
union all
select c2 as m,v2 as n from a
union all
select c3 as m,v3 as n from a
²»ÊÇÕâÑù×ӵģ¬c1,c2,c2ÊÇÁÐÃû£¬ÒªÔÚ#tÀïÃæÓÐÁÐÃû
SQL code:
--ÁÙʱ±í²»´æÔÚ
select
*
into
#t
from
(
select c1 as m,v1 as n from a
union all
select c2 as m,v2 as n from a
union all
select c3 as m,v3 as n from a
)t
----ÁÙʱ±í´æÔÚ
insert into #t(m,n) select * from (
select c1 as m,v1 as n from a
union all
select c2 as m,v2 as n from a
union all
select c3 as m,v3 as n from a
)t
SQL code:
declare @A table (col1 varchar(2),col2 varchar(2),col3 varchar(2))
insert into @A
select 'c1','c2','c3' union all
select count(1) from FX_RETURNBOOKCHECKLIST fxreturnbo0_ where fxreturnbo0_.BOOKID='164 ' AND fxreturnbo0_.RETURNID='00025.S0000001'
ÉÏÃæÒ»¸ö¼òµ¥µÄSQL,Ö´ÐÐʱ¼ä2.6à ......