I'm trying to INSERT a value in a column, the result of a SELECT this sentence works fine:
insert into tempdepa (Trabajadores) (select count (DepartmentName) from DimEmployee where DepartmentName = @d) But I want to insert that SELECT into a specific column:
insert into tempdepa (Trabajadores) (select count (DepartmentName) from DimEmployee where DepartmentName = @d) where id = @cont
This last where id = @cont is from the first table (tempdepa)... I tried
insert into tempdepa (Trabajadores where id = @cont) (select count (DepartmentName) from DimEmployee where DepartmentName = @d) but it doesn't work. How can I do it?
UPDATEinstead of anINSERTif you want to change the value of an existing row! TheINSERTcannot be "parametrized" with aWHEREclause - it just inserts a new row.