I have 2 tables 1 [dbo].[t_Olympic_Country] where i have all the county list but population and GDP is empty. Now i have second table which has most of the countries with population and GDP data but its it has not same number of data. I would like to enter value of GDP and population from 2nd temp table [dbo].[temptable1] to first [dbo].[t_Olympic_Country] in case the cuntry name matches with [dbo].[t_Olympic_Country]. I mean a conditional bulk update for [dbo].[t_Olympic_Country]. Can anybody help me? i tried following which gives error :
INSERT INTO [dbo].[t_Olympic_Country]( [GDP]
) SELECT temp.[GDP] FROM [dbo].[temptable1] temp WHERE (temp.[Country_Name] IN (SELECT tl.[Country_Name] FROM [dbo].[t_Olympic_Country] tl)) and temp.Country_Name not like 'Indep. Olympic Participants' order by temp.[Country_Name]Msg 515, Level 16, State 2, Line 1
**Caot insert the value NULL into column 'Country_Id', table 'Olympic.dbo.t_Olympic_Country'; column does not allow nulls. INSERT fails.
The statement has been terminated. asc**
Please find my table structure as follows: [dbo].[t_Olympic_Country]: Country_Id Country_Name Country_Size c_population GDP 1 Afghanistan Null Null NULL 2 Albania Null Null NULL 3 Algeria Null Null NULL 4 American Samoa Null Null NULL 5 Andorra Null Null NULL
[dbo].[temptable1]: Country_Name GDP c_population Afghanistan 20038215159.38730 31627506 Albania 13211513725.58810 2894475 Algeria 213518488688.12000 38934334 American Samoa 645000000.00000 55434 Andorra 3249000000.00000 72786
