update tb set c =t.c from tb1 where tb.id=tb.id and isnull(tb.c,'')='' --?????????
Insert into Table(a, c, d) select x,y,z from anothertable a where not exists(select 1 from Table where c=a.y)
我就是用Insert into Table(a, c, d) 又想查找select c from Table一下表里如果没有c才做Insert into Table(a, c, d)
c 是什么? 如果c 是从另一个表中查得的,那见3楼. 如果c 是一个变量值 @c,则: if not exists(select 1 from table where c=@c) insert into table(a,c,d)values(@a,@c,@d) 注意,既然insert into table(a,c,d)了,则后面必须有三个插入值.
我就是用Insert into Table(a, c, d) 又想查找select c from Table一下表里如果没有c才做Insert into Table(a, c, d) if not exists(select 1 from [table] where ...) Insert into Table(a, c, d)
set c =t.c
from tb1
where tb.id=tb.id
and isnull(tb.c,'')=''
--?????????
又想查找select c from Table一下表里如果没有c才做Insert into Table(a, c, d)
如果c 是从另一个表中查得的,那见3楼.
如果c 是一个变量值 @c,则:
if not exists(select 1 from table where c=@c)
insert into table(a,c,d)values(@a,@c,@d)
注意,既然insert into table(a,c,d)了,则后面必须有三个插入值.
又想查找select c from Table一下表里如果没有c才做Insert into Table(a, c, d) if not exists(select 1 from [table] where ...)
Insert into Table(a, c, d)