Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Returned more than one Value
    text
    copied!<p>Im sure this is simple and i will kick myself when i find out but ive been sitting on this problem for the last hour and im getting annoyed with it, could anyone help me.</p> <p>So i am trying to enter a DeviceId and ConfigurationId Column the values are the primary keys from a Device table and a Configuration table. Yes thats really all the problem is.</p> <p>I tried using <code>(SELECT ID FROM DeviceId)</code> But that comes up with the error,</p> <p><code>Subquery returned more than 1 value</code></p> <p>Here is the code i am using the <code>GETDATE()</code>'s are just place holders at the moment and the C.Values are me shredding some XML into the table.</p> <pre><code>INSERT INTO [Container].[dsc].[DeviceConfiguration] ( DateInserted, DeviceId, ConfigurationId, DateRegistered, DateRemoved, OperatingSystemInstallDate, OperatingSystemSerialNumber ) SELECT GETDATE(), &lt;This will need to be DeviceId&gt;, &lt;This will need to be the ConfigurationId&gt;, GETDATE(), GETDATE(), C.value('@OSInstallDate', 'datetime'), C.value('@OSSerialNumber', 'nvarchar(125)') FROM [test].[HardwareComponent] CROSS APPLY HardwareComponent.ComponentXmlData.nodes('OSData')AS T(C) WHERE HardwareComponent.TypeId = 7 </code></pre> <p>Edit: More info sorry, The 2 columns are set as foreign keys.</p> <pre><code>ALTER TABLE [dsc].[DeviceConfiguration] WITH CHECK ADD CONSTRAINT FK_DeviceConfiguration_Device FOREIGN KEY (DeviceId) REFERENCES [dsc].[Device](Id); GO ALTER TABLE [dsc].[DeviceConfiguration] WITH CHECK ADD CONSTRAINT FK_DeviceConfiguration_Configuration FOREIGN KEY (ConfigurationId) REFERENCES [dsc].[Configuration](Id); GO </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload