У меня есть хранимая процедура, которая возвращает много столбцов и с которой очень трудно работать, я создал еще одну хранимую процедуру, которая преобразует строки в столбцы. Как вставить столбцы из подпроцедуры в основную процедуру?
Мне кажется, что я хочу поместить столбцы из подпроцедуры, которую я кодирую следующим образом:
(select * from subprocedure where X= 1) as subquerycolumns
это правильно?
Вот моя табличная функция, однако я получаю сообщение об ошибке «Префикс столбца IPAM_RIPS_SKILL-SET_PARTICIPANT_RATING_HDR» не совпадает с именем таблицы или псевдонимом ... », хотя все выглядит хорошо, может кто-то мне помочь
CREATE FUNCTION PARTICIPANTRATINGSET
(@PARTICIPANT_ID INT)
RETURNS TABLE
AS
RETURN
SELECT
ST1.SKILL_SET_ID AS SET1, SS1.SET_NAME AS NAME1, ST1.SKILL_SET_RATING AS R1,
ST2.SKILL_SET_ID AS SET2, SS2.SET_NAME AS NAME2, ST2.SKILL_SET_RATING AS R2,
ST3.SKILL_SET_ID AS SET3, SS3.SET_NAME AS NAME3, ST3.SKILL_SET_RATING AS R3,
ST4.SKILL_SET_ID AS SET4, SS4.SET_NAME AS NAME4, ST4.SKILL_SET_RATING AS R4,
ST5.SKILL_SET_ID AS SET5, ST5.SKILL_SET_OPTIONAL AS NAME5, ST5.SKILL_SET_RATING AS R5,
ST6.SKILL_SET_ID AS SET6, ST6.SKILL_SET_OPTIONAL AS NAME6, ST6.SKILL_SET_RATING AS R6,
ST7.SKILL_SET_ID AS SET7, ST7.SKILL_SET_OPTIONAL AS NAME7, ST7.SKILL_SET_RATING AS R7,
CM.COMMENTS
FROM IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_HDR HT
LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST1
ON HT.ID = ST1.HDR_ID and st1.SKILL_SET_ID = 1
INNER JOIN IPAM_RIPS_SKILL_SETS SS1
ON ST1.SKILL_SET_ID = SS1.ID
LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST2
ON HT.ID = ST2.HDR_ID and st2.SKILL_SET_ID = 2
INNER JOIN IPAM_RIPS_SKILL_SETS SS2
ON ST2.SKILL_SET_ID = SS2.ID
LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST3
ON HT.ID = ST3.HDR_ID and st3.SKILL_SET_ID = 3
INNER JOIN IPAM_RIPS_SKILL_SETS SS3
ON ST3.SKILL_SET_ID = SS3.ID
LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST4
ON HT.ID = ST4.HDR_ID and st4.SKILL_SET_ID = 4
INNER JOIN IPAM_RIPS_SKILL_SETS SS4
ON ST4.SKILL_SET_ID = SS4.ID
LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST5
ON HT.ID = ST5.HDR_ID and st5.SKILL_SET_ID = 5
INNER JOIN IPAM_RIPS_SKILL_SETS SS5
ON ST5.SKILL_SET_ID = SS5.ID
LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST6
ON HT.ID = ST6.HDR_ID and st6.SKILL_SET_ID = 10
INNER JOIN IPAM_RIPS_SKILL_SETS SS6
ON ST6.SKILL_SET_ID = SS6.ID
LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST7
ON HT.ID = ST7.HDR_ID and st7.SKILL_SET_ID = 11
INNER JOIN IPAM_RIPS_SKILL_SETS SS7
ON ST7.SKILL_SET_ID = SS7.ID
INNER JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_COMMENTS CM
ON HT.ID = CM.HDR_ID
WHERE IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_HDR.PARTICIPANT_ID = @PARTICIPANT_ID
GROUP BY PARTICIPANT_ID, ST1.SKILL_SET_ID, SS1.SET_NAME, ST1.SKILL_SET_RATING, ST2.SKILL_SET_ID, SS2.SET_NAME, ST2.SKILL_SET_RATING, ST3.SKILL_SET_ID, SS3.SET_NAME, ST3.SKILL_SET_RATING, ST4.SKILL_SET_ID, SS4.SET_NAME, ST4.SKILL_SET_RATING, ST5.SKILL_SET_ID, ST5.SKILL_SET_OPTIONAL, ST5.SKILL_SET_RATING, ST6.SKILL_SET_ID, ST6.SKILL_SET_OPTIONAL, ST6.SKILL_SET_RATING, ST7.SKILL_SET_ID, ST7.SKILL_SET_OPTIONAL, ST7.SKILL_SET_RATING, CM.COMMENTS
GO