sql >> Base de Datos >  >> RDS >> Sqlserver

inserte un registro en una tabla copiando una sola fila de una sola columna de otra tabla

No puede tener dos cláusulas WHERE en una declaración:

insert into RECEIVE(Aname , Permission)
  select Aname , 'select' 
  from SEND
  WHERE Aname = 'GREAME'   <=== WHERE #1
  where not exists         <=== WHERE #2
    (select *  from RECEIVE where aname = 'GREAME' and Permission = 'select')

Debe cambiar la segunda parte a AND:

insert into RECEIVE(Aname , Permission)
  select Aname , 'select' 
  from SEND
  WHERE Aname = 'GREAME'  
  AND not exists
    (select *  from RECEIVE where aname = 'GREAME' and Permission = 'select')