I have the following code that returns the last value in a table Column 'MatchID':
SELECT TOP 1 MatchID FROM BetfairFootballDB..Match
ORDER BY MatchID DESC;
I have another table called 'Data' with a Foreign Key column, also named MatchID. I have imported data from a csv file, to a temporary table, which contains all of the correct data except for the MatchID. I have added the MatchID column to the imported data table, but all of the values in that column are currently NULL. I need to write the queried value from the code above, to all cells in the MatchID column of my imported data, so that I can then finally write all of the data to my 'Data' table. Please could somebody let me know how this can be done in SQL Server. Thanks
EDIT: As requested, here is my temporary table. Note that the number of rows of data could be any length:
FirstTimeTaken LatestTimeTaken Market Outcome Odds NumberOfBets VolumeMatched InPlay MatchID
2013-03-08 14:04:24.000 2013-03-08 15:22:57.000 Over/Under 3.5 Goals Over 3.5 Goals 4 4 58 1 NULL
2013-03-08 14:40:08.000 2013-03-08 15:03:09.000 Match Odds The Draw 5 45 405 1 NULL
2013-03-08 13:20:37.000 2013-03-08 13:20:37.000 Half Time/Full Time Draw/Wigan 6 2 5 0 NULL
2013-03-08 10:17:21.000 2013-03-08 10:17:37.000 DRAW NO BET Wigan 2 5 36 0 NULL