이 나는 조건에 따라 저장 프로 시저 내 테이블에 값을 삽입하려고 :삽입 값은 SQL Server
alter procedure service_report_st2
as
insert into Service_report_step1(appointment_or_house)
select
case
when Service_report_step1.card_uid in(select card_uid from visits where vidpos_kod = 'A')
then '1'
when Service_report_step1.card_uid in(select card_uid from visits where vidpos_kod = 'B')
then '2'
else '3'
end
오류가 Service_report_step1.card_uid
에서 발견되지 않는 것입니다, 그러나 이것은이다 Service_report_step1
의 첫 번째 열. appointment_or_house
은 visits
테이블에 이 포함되어 있으면 Service_report_step1
에 '1', '2'또는 '3'을 포함해야하는 두 번째 열입니다.
도움을 주시면 감사하겠습니다.
짧은 예 :
Visits
표는 2 열이 있습니다 Card_uid 및 vidpos_kod
card_uid vidpos_kod
111-111 A
222-222 B
333-333 A
444-444 C
지금 Service_report_step1
테이블 card_uid있다 (모든 가능한 카드를 포함 열) 및 appointment_or_house 열
card_uid appointment_or_house
111-111 1
222-222 2
333-333 1
444-444 1
을 그래서 card_uids
이 Service_report_step1
에있는 경우와 같습니다. I는 554,133,210 Visits
에 vidpos_kod
에 기초 appointment_or_house
열을 결정 I 예에서와 같이 정확하게 Service_report_step1
모든 데이터에 삽입해야
(A, C
는 '1', B
는 '2'이다).
사용하는 것입니다 ..... –