主键上的SQL插入错误

时间:2016-09-28 14:36:45

标签: sql-server

我有以下查询。一个表上的主键是RecID。它不是插入的一部分,但是我收到了这个错误:

  

无法将值NULL插入“RecId”列,表'APMGMEE.dbo.APMProducts';列不允许空值。 INSERT失败。

不确定为什么会这样。如果找到,RecID必须存在。

INSERT INTO APMGMEE.dbo.APMProducts (ProductCode, FundMonitor, StatusAPM, StatusAPMArena, StatusSales, PerformanceUpdateType) 
    SELECT 
        ap.ProductCode, ap.FundMonitor, ap.StatusAPM, ap.StatusAPMArena, 
        ap.StatusSales, ap.PerformanceUpdateType 
    FROM 
        APMGMEE.dbo.APMProducts p 
    JOIN 
        Neptune.dbo.Approved_Products ap ON p.ProductID = AltID 
    WHERE 
        RecID IN ('3D31B1CE69D64AF0B319E1F21F95FEBB', '87574C0E1262442384D93C9B24C19344', '20331407649843E7BFF73B53BBADF438','802FF02E11F5482E9E3A9737A5A7CF29',
                '506D0AC67F5E4EEFB97CBBF0400A1686','6766FC5613BE4906A7E234E774F13D6C','46CAF4A0C6584B32B0B4234669C89000','9868B104368146D69C43921B59B19732',
                'B57D7B5B32F04902A4028226346571D5', '331C48F680134C7F99A74B8BAFD39ED0', 'B555FB9065124D81B25DF12C1CB8DA41', '49815A16337348EBB77A1A49A8D86240',
                '78A629CC22D84FE0A03FB96A160481C0', '2CE56D518D6646B1AEFE51B745A9830D', '44B6B7FEFA8E49ACAAC9BA3B498B8451', '4175A84F05BF4B92B40D16277A8F31BC',
                'E441B61B9E834BC4977EA724DBA382AE', '8CA65C4B678140AE9394A3322F2B4C90', 'D24C7ACAF87D40D08D641AB3F3182409', '45D378C607B444F9936F44CE9D679D18',
                'D327B2686A4D4705822982848D065CBE', 'D861299DEA54443585C52BA4F5BC9D54', 'A466139D554243A5B01C4655712E23FE', '6836385BE28149B0ACC6000376DF4349',
                'AB8B0E3862444CBC908A12AEFB651923', 'E6F8B6263C7B445695AB0D0E3083B8BA', '1D8A27657BFF428EA7DB3FE9C0BBD7ED', 'F01C4E1130AE4291A3F4A002F3F26EDE',
                '0C54655401894726BA63E33A5864B0B7', 'F8E36CE6FE3C4759B2BF227E70B26BFD', 'AA7B56C144BF4E4DBB2A5C07E21E792A', 'E28A9A4DA31843F4BD24076F87458F64',
                'E80FCCE1736347AE833D76502D0209A3', 'E804F160A30E460E9BB1A542E671A2CB', 'BB874AA2C02242F6B21E4BEE9251ADB5', 'C240E7BC4AD94355BAEBDA72B2FD725B',
                '8B6B3C30610A4001800F4BB6FF1EBE37', 'F01E911FB4044E8DBA770BC7D38F0D2B', '11144B3081B341E0AA667204EDA7D456', '952AC4BF9D6E4FE0AF44DDFC9AA27166',
                '9BF4505503AB447DA192FCFB56FC2D8F','EEDD1F2FDA29455198CA31658766A43F','2CF6178A163E4691BC4ACC49F83D52FB',
                '6C45FB48F5C94754839F794F1D00D4EB','995FE6F276CE40B2AE8DE822F587FB1A','5648A303B0EE421EBF1986A7703FE1BF',
                '6EE5B9ABBF544A9E956299798169CC37','0CE251DF93AF480A9CC20FB3F93AEE01','311ECBB39FAB4C5C8BE6BECA032A0FF4','CCCD4D8D934D4D99ADE316EF10147126',
                '8F63DFDE7FB5497099236E85DA6C38A0','EB8F01D0B2CE45848D835DB9A2A7F3EF',
                '3CF861D930154C3F81567D2B0DDBDA47','4207EB56C6584552A555C053285AACEA','06051E3B378747A09504386FEEF2E88A',
                '6C8164FAC0F043C584995210759FC811','B10481CE89A04038919AD7FF84240E3E',
                'DA16667BBB9643A89923D8EE104B23C1','2EDC2E3D50DF49F59D13E5B440E1849D','3C5C1358FD5542D5A29D3F26D6FD63BB','71D358D0AA6D4353998AD0CF9DF6E2AC',
                'ADBB5C2B9DD84D0F99C083A38DCC831D','1EC171D7DB7B403CA13522DE7755E90E',
                'E0E8F792B5924199B2A97F533E02DEC7','10105534977B43CDADDF857824405E9B',  '996B4300EA50488CAD4C2F18630D0F5C','E06649C8A4E64144A2C140749025A8BB',
                '2057433562614B78BA33B284B149DC4B','EFFD08B973C44A898065181ECF8EFCBA', '98CCC454E0124183BF997D443BA23BB5', 'B6B343FF818140ADA2EC7A6CAD4704F9',
                'B77F60E49A57493B904B816C5D2A0600','2647DB017C37495D8E114E7CB7868F2F', '10105534977B43CDADDF857824405E9B', '1EC171D7DB7B403CA13522DE7755E90E',
                '400972689102452C83785AF0404A6E87','41D3B6D5760A4A9CB9A1EC189E2D5A2A', '66ACB1B7B153486DA0131D15DF530D7D', '73F446E9D8DD4593B53698B178863D72',
                '800433A741A543A4A3DEC2C67E79683B', '8F5C82FB3EFE4B1EBD7F980D4E4744BA', '8CC16E8C26F34BFFAA6FA7BC33E9438B', '98CCC454E0124183BF997D443BA23BB5',
                '991B322ACFDA476BAA8B40E246E2A62C', '996B4300EA50488CAD4C2F18630D0F5C', 'B6B343FF818140ADA2EC7A6CAD4704F9', 'DAD50684496B40DB9E706DB63BB3066C',
                'E06649C8A4E64144A2C140749025A8BB', 'E0E8F792B5924199B2A97F533E02DEC7', 'E4E296560EBB49CB930B58D0AC457BD5',  'B0434D8ED1644CA9BD86219AF214EA15',
                '501D8D4617394C21876E435657F520F9', 'E891700D87084D4BB98E5D7897672FC0')

1 个答案:

答案 0 :(得分:0)

看起来你的RecID是主键但不是自动填充的(如身份) 您需要在列列表中给出RecID列和列表的值以进行插入或使RecID列自动填充。