我想用佔位符列創建一個存儲過程。我的意思是,我正在使用當前表中不存在的列名,但這些列稍後將添加到表中。我可以在存儲過程中使用佔位符列來存儲未來的值嗎?
SQL有沒有可能爲將來的條目保留佔位符?
2列identity
和sexualorientation
,它遵循以下規則:
For Identity
If Identity = 'M', display 'Male'.
If Identity = 'F', display 'Female'.
If Identity = 'x1', display 'Trans Male/Trans Man'.
If Identity = 'x2', display 'Trans Female/Trans Woman'.
If Identity = 'x3', display 'Genderqueer/Gender Non-Conforming'.
For Sexual Orientation,
If Sexual Orientation = 'x1', display 'Gay'.
If Sexual Orientation = 'x2', display 'Lesbian'.
If Sexual Orientation = 'x3', display 'Straight'.
If Sexual Orientation = 'x4', display 'Bisexual'.
If Sexual Orientation = 'x5', display 'Pansexual (or Omnisexual)'.
If Sexual Orientation = 'x6', display 'Queer'.
If Sexual Orientation = 'x7', display 'Asexual'.
If Sexual Orientation = 'x8', display 'Questioning'.
這是我想使用的代碼:
select stu_id,case
when 'M' then 'MALE'
when 'F' then 'FEMALE'
when 'X1' then 'Trans Male/Trans Man'
when 'X2' then 'TransFemale/TransWoman'
when 'X3' then 'Genderqueer/Gender Non-Conforming'
end as 'Identity'
, case
when 'x1' then 'Gay'
when 'x2' then 'Lesbian'
when 'X3' then 'Straight'
when 'X4' then 'Bisexual'
when 'X5' then 'Pansexual (or Omnisexual)'
when 'x1' then 'Queer'
when 'x1' then 'Asexual'
when 'x1' then 'Questioning'
end as sexualOrientation
, it.INDV_TAX_ID
, it.[BIRTH_DATE]
,vt.DECEASED_FL
FROM DBO.ID0UIT it join dbo.sr0skt kt on it.[UCLA_ID] = kt.[STU_ID]
join dbo.si0_stu_attr ar on it.UCLA_ID = ar.STU_ID
join dbo.SR0PVT vt on it.UCLA_ID = vt.STU_ID
我不明白「* spaceholds *」是什麼意思......您是否試圖向表中尚不存在的select語句添加一列? – Siyual
您可以使用像'M'這樣的常量作爲未來列的去向。 –
是的,我想添加不存在的列 – sam