I have a temporary table which I'm using individual queries to insert data into.How can I use an INSERT statement to insert data into an existing row based on existing data matches?DECLARE @tblResults TABLE ( [Club] CHAR(20), [First] DECIMAL (9,2), [Second] DECIMAL (9,2))INSERT INTO @tblResults (club, First)SELECT stuffFROM stuffGROUP BY clubINSERT INTO @tblResults (club, Second)SELECT stuffFROM stuffGROUP BY club
If there are 3 clubs then the above will create 6 rows within the temporary table. I'd like the second query to insert it's results into the appropriate existing rows based on the club.I've done a search and people reference "WHERE EXISTS (Select * from TABLE WHERE @tblResults.club = query.club)" but that doesn't seem to work.As always - many thanks!