1
我有2個表格:students
,ece200_atten
。存儲過程中的IF條件
- 第一臺
students
有2列:id, ece200
,但ece200
是bit
=> true或false - 二表
ece200_attend
有一欄id
當我插入id
我要檢查(如果這個ID的ece200 = 1)在表ece200_attend中插入該ID。
我的代碼:
alter proc test
@myid int
as
begin
declare @mycourse bit = 1
select @mycourse = ece200 from students
if @mycourse = 1
insert into ece200_attend (id) values (@myid)
end
go
exec test 34003
所以什麼問題你的代碼? – KumarHarsh