insert row when not exists and select statement uses subqueries
<p>I need to insert unique rows to table but don't know how to use where not exists when my Select uses subqueries for 2 columns.  Is there a way to do this?</p>

<p>BTW: I do have constraints on the table and duplicates can't be inserted but would like to avoid duplicate key errors.</p>

<p>I tried this format but due to subqueries, columns couldn't be bound.</p>

<pre><code>INSERT dbo.DataValue(DateStamp, ItemId, Value)
SELECT DateStamp, ItemId, Value 
FROM dbo.tmp_holding_DataValue AS t
WHERE NOT EXISTS (SELECT 1 FROM dbo.DataValue AS d
WHERE DateStamp = t.DateStamp
AND ItemId = t.ItemId);
</code></pre>

<p>My query:</p>

<pre><code>insert into App.DimRequirementComponentDetail_TST 
(RequirementComponentSID, RequirementComponentDimensionSID, RequirementComponentDimensionValueSID,RequirementComponentDimensionValueText, Sta3n, ActiveFlag)  

select (select RequirementComponentSID from App.DimRequirementComponent  where name = @Measure ),   --   'PTSD PSY11' 
(select RequirementComponentDimensionSID from App.DimRequirementComponentDimension  where Name='ICD10 Diagnosis') , 
t1.ICD10SID,cast(t1.ICD10Code as varchar(max)),t1.Sta3n,'Y'--,t1.ICD10Description 
from app.DimICD10 t1 
where ICD10Code = @ICD10Code   --'F32.5'
</code></pre>