急!!!!!请大家帮忙
create table #a
(
TagId int not null,
Target nvarchar(max) not null,
sendmode nvarchar(20) not null,
languge nvarchar(3) not null,
count int not null,
interval int not null
)
insert into #a select TagId, 'L '+cast(AreaId as nvarchar(100)) , 'LED ', 'CHT ' ,1 ,0 from TAlarmTag where TagId not in (select TagId from TAlarmSending)
单独执行 select TagId, 'L '+cast(AreaId as nvarchar(100)) , 'LED ', 'CHT ' ,1 ,0 from TAlarmTag where TagId not in (select TagId from TAlarmSending)
各列均有值 如:
3 L2 LED CHT 1 0
4 L3 LED CHT 1 0
5 L3 LED CHT 1 0
6 L3 LED CHT 1 0
7 L3 LED CHT 1 0
8 L3 LED CHT 1 0
10 L2 LED CHT 1 0
11 L3 LED CHT 1 0
12 L2 LED CHT 1 0
13 L2 LED CHT 1 0
14 L2 LED CHT 1 0
15 L2 LED CHT 1 0
16 L2 LED CHT 1 0
17 L2 LED CHT 1 0
18 L2 LED CHT 1 0
19 L2 LED CHT 1 0
但是整个执行插入语句时确显示“無法插入 NULL 值到資料行 'Target ',資料表 'AlarmTest.dbo.TAlarmSending '; 資料行不得有 Null。INSERT 失敗”
实在看不出有什么错啊,请大家帮忙!!!!!!!!
[解决办法]
Try:
insert into #a select TagId, 'L '+cast(AreaId as nvarchar(100)) , 'LED ', 'CHT ' ,1 ,0 from TAlarmTag where TagId not in (select TagId from TAlarmSending where TagId is not null)