INSERT INTO with PK andFK I have the following problem:

I created two tables:

CREATE TABLE DimServers 
(
    [ID_DimServer] INT NOT NULL IDENTITY(1,1) PRIMARY KEY ,
    [ServerName] VARCHAR(13) NOT NULL,
    [Domain] VARCHAR(10) NOT NULL,
    [PIT] VARCHAR(4),
    [PhysicalMemoryMB] INT,
    [AvailablePhysicalMemoryMB] INT,
    [MemoryInUseMB] INT,
    [CPU] INT,
    [HyperthreadRatio] INT,
    [SystemUpTime] VARCHAR(50),
    [WindowsVersion] VARCHAR(50) NOT NULL
)

CREATE TABLE DimDrives 
(
    [ID_DimDrive] INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
    [DimServer_ID] INT FOREIGN KEY REFERENCES DimServers(ID_DimServer),
    [Drive] VARCHAR(1) NOT NULL)
)


After that I do an INSert with data from an another server:

INSERT INTO DimServers 
(
    [ServerName],
    [Domain],
    [PIT],
    [PhysicalMemoryMB],
    [AvailablePhysicalMemoryMB],
    [MemoryInUseMB],
    [CPU],
    [HyperthreadRatio],
    [SystemUpTime],
    [WindowsVersion]
)
SELECT
     sq.[ComputerNamePhysicalNetBIOS],
     sq.[Domain],
     sq.[PIT],
     sq.[TotalPhysicalMemoryMB],
     sq.[AvailPhysicalMemoryMB],
     sq.[MemInUseMB],
     sq.[cpu_count],
     sq.[hyperthread_ratio],
     sq.[SystemUpTime],
     sq.[WindowsVersion]
FROM [x].[y].[dbo].[sqlsysinfo] as sq


Now I don't know how to do it, if it has a foreign key.
Since it doesn't appear that DimServers references any other tables, you should not have any problems inserting rows into that table.

However, DimDrives has a foreign key reference to DimServers.  When you insert any rows into DimDrives, the value that is in the DimServer_ID column MUST exist in the column ID_DimServer on the DimServers table.

If you attempt to insert a row in the DimDrives table where the column value for DimServer_ID does NOT exist in the DimServers table in the column ID_DimServer, you'll get a foreign key violation error

The INSERT statement conflicted with the FOREIGN KEY constraint