Inserting rows from one table to another where match occurs The Next CEO of Stack OverflowInsert into … values ( SELECT … FROM … )Best way to get identity of inserted row?How to concatenate text from multiple rows into a single text string in SQL server?Select columns from result set of stored procedureSQL update from one Table to another based on a ID matchInserting multiple rows in a single SQL query?Insert results of a stored procedure into a temporary tableSelect n random rows from SQL Server tableSQL Server: How to Join to first rowHow to select rows with no matching entry in another table?

How to start emacs in "nothing" mode (`fundamental-mode`)

Trouble understanding the speech of overseas colleagues

How easy is it to start Magic from scratch?

Why Were Madagascar and New Zealand Discovered So Late?

Whats the best way to handle refactoring a big file?

Anatomically Correct Mesopelagic Aves

How to make a software documentation "officially" citable?

Removing read access from a file

Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?

Why is there a PLL in CPU?

Anatomically Correct Strange Women In Ponds Distributing Swords

How to write the block matrix in LaTex?

Too much space between section and text in a twocolumn document

What does this shorthand mean?

How long to clear the 'suck zone' of a turbofan after start is initiated?

What can we do to stop prior company from asking us questions?

Implement the Thanos sorting algorithm

Visit to the USA with ESTA approved before trip to Iran

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

Customer Requests (Sometimes) Drive Me Bonkers!

Return of the Riley Riddles in Reverse

Why does GHC infer a monomorphic type here, even with MonomorphismRestriction disabled?

How to safely derail a train during transit?

How to use tikz in fbox?



Inserting rows from one table to another where match occurs



The Next CEO of Stack OverflowInsert into … values ( SELECT … FROM … )Best way to get identity of inserted row?How to concatenate text from multiple rows into a single text string in SQL server?Select columns from result set of stored procedureSQL update from one Table to another based on a ID matchInserting multiple rows in a single SQL query?Insert results of a stored procedure into a temporary tableSelect n random rows from SQL Server tableSQL Server: How to Join to first rowHow to select rows with no matching entry in another table?










-1















I have two tables PRODUCTION_HISTORY and BULK_INSERT. I am trying to insert values from TEST_Custom_DataSets column from BULK_INSERT table to CUSTOM_DATASETS in the PRODUCTION_HISTORY table where the WELL_KEY matches but I am getting the following error:




The multi-part identifier "dbo.PRODUCTION_HISTORY.WELL_KEY" could not be bound.




Following is my query:



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS)
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT]
WHERE [dbo].[BULK_INSERT].WELL_KEY = dbo.PRODUCTION_HISTORY.WELL_KEY


Any advice would be greatly appreciated!










share|improve this question



















  • 1





    Use a join in your select statement.

    – Sean Lange
    Mar 21 at 16:35











  • I don't see table dbo.PRODUCTION_HISTORY in your query.

    – Eric
    Mar 21 at 16:54















-1















I have two tables PRODUCTION_HISTORY and BULK_INSERT. I am trying to insert values from TEST_Custom_DataSets column from BULK_INSERT table to CUSTOM_DATASETS in the PRODUCTION_HISTORY table where the WELL_KEY matches but I am getting the following error:




The multi-part identifier "dbo.PRODUCTION_HISTORY.WELL_KEY" could not be bound.




Following is my query:



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS)
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT]
WHERE [dbo].[BULK_INSERT].WELL_KEY = dbo.PRODUCTION_HISTORY.WELL_KEY


Any advice would be greatly appreciated!










share|improve this question



















  • 1





    Use a join in your select statement.

    – Sean Lange
    Mar 21 at 16:35











  • I don't see table dbo.PRODUCTION_HISTORY in your query.

    – Eric
    Mar 21 at 16:54













-1












-1








-1








I have two tables PRODUCTION_HISTORY and BULK_INSERT. I am trying to insert values from TEST_Custom_DataSets column from BULK_INSERT table to CUSTOM_DATASETS in the PRODUCTION_HISTORY table where the WELL_KEY matches but I am getting the following error:




The multi-part identifier "dbo.PRODUCTION_HISTORY.WELL_KEY" could not be bound.




Following is my query:



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS)
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT]
WHERE [dbo].[BULK_INSERT].WELL_KEY = dbo.PRODUCTION_HISTORY.WELL_KEY


Any advice would be greatly appreciated!










share|improve this question
















I have two tables PRODUCTION_HISTORY and BULK_INSERT. I am trying to insert values from TEST_Custom_DataSets column from BULK_INSERT table to CUSTOM_DATASETS in the PRODUCTION_HISTORY table where the WELL_KEY matches but I am getting the following error:




The multi-part identifier "dbo.PRODUCTION_HISTORY.WELL_KEY" could not be bound.




Following is my query:



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS)
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT]
WHERE [dbo].[BULK_INSERT].WELL_KEY = dbo.PRODUCTION_HISTORY.WELL_KEY


Any advice would be greatly appreciated!







sql sql-server tsql bulkinsert






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 16:36









Andrea

7,781144954




7,781144954










asked Mar 21 at 16:30









AlexAlex

1




1







  • 1





    Use a join in your select statement.

    – Sean Lange
    Mar 21 at 16:35











  • I don't see table dbo.PRODUCTION_HISTORY in your query.

    – Eric
    Mar 21 at 16:54












  • 1





    Use a join in your select statement.

    – Sean Lange
    Mar 21 at 16:35











  • I don't see table dbo.PRODUCTION_HISTORY in your query.

    – Eric
    Mar 21 at 16:54







1




1





Use a join in your select statement.

– Sean Lange
Mar 21 at 16:35





Use a join in your select statement.

– Sean Lange
Mar 21 at 16:35













I don't see table dbo.PRODUCTION_HISTORY in your query.

– Eric
Mar 21 at 16:54





I don't see table dbo.PRODUCTION_HISTORY in your query.

– Eric
Mar 21 at 16:54












2 Answers
2






active

oldest

votes


















1














Pretty sure you just need to join those two tables together in your select statement.



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS) 
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT] AS bi
JOIN dbo.PRODUCTION_HISTORY AS ph
ON bi.WELL_KEY = ph.WELL_KEY





share|improve this answer

























  • So it executed well but also updated all the nulls all the way up to 76k rows. Is there a way to only update the ones that have well_key data not as null? thanks

    – Alex
    Mar 21 at 17:16


















0














I suspect you want update, not insert:



UPDATE ph
SET CUSTOM_DATASETS = bi.Test_Custom_DataSets
FROM [dbo].[PRODUCTION_HISTORY] pn JOIN
[dbo].[BULK_INSERT] bi
ON bi.WELL_KEY = pn.WELL_KEY;





share|improve this answer























  • Thanks it worked!

    – Alex
    Mar 21 at 17:58











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285116%2finserting-rows-from-one-table-to-another-where-match-occurs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Pretty sure you just need to join those two tables together in your select statement.



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS) 
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT] AS bi
JOIN dbo.PRODUCTION_HISTORY AS ph
ON bi.WELL_KEY = ph.WELL_KEY





share|improve this answer

























  • So it executed well but also updated all the nulls all the way up to 76k rows. Is there a way to only update the ones that have well_key data not as null? thanks

    – Alex
    Mar 21 at 17:16















1














Pretty sure you just need to join those two tables together in your select statement.



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS) 
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT] AS bi
JOIN dbo.PRODUCTION_HISTORY AS ph
ON bi.WELL_KEY = ph.WELL_KEY





share|improve this answer

























  • So it executed well but also updated all the nulls all the way up to 76k rows. Is there a way to only update the ones that have well_key data not as null? thanks

    – Alex
    Mar 21 at 17:16













1












1








1







Pretty sure you just need to join those two tables together in your select statement.



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS) 
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT] AS bi
JOIN dbo.PRODUCTION_HISTORY AS ph
ON bi.WELL_KEY = ph.WELL_KEY





share|improve this answer















Pretty sure you just need to join those two tables together in your select statement.



INSERT INTO [dbo].[PRODUCTION_HISTORY] (CUSTOM_DATASETS) 
SELECT Test_Custom_DataSets
FROM [dbo].[BULK_INSERT] AS bi
JOIN dbo.PRODUCTION_HISTORY AS ph
ON bi.WELL_KEY = ph.WELL_KEY






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 21 at 16:39









Arnaud Peralta

977718




977718










answered Mar 21 at 16:37









Sean LangeSean Lange

26k21935




26k21935












  • So it executed well but also updated all the nulls all the way up to 76k rows. Is there a way to only update the ones that have well_key data not as null? thanks

    – Alex
    Mar 21 at 17:16

















  • So it executed well but also updated all the nulls all the way up to 76k rows. Is there a way to only update the ones that have well_key data not as null? thanks

    – Alex
    Mar 21 at 17:16
















So it executed well but also updated all the nulls all the way up to 76k rows. Is there a way to only update the ones that have well_key data not as null? thanks

– Alex
Mar 21 at 17:16





So it executed well but also updated all the nulls all the way up to 76k rows. Is there a way to only update the ones that have well_key data not as null? thanks

– Alex
Mar 21 at 17:16













0














I suspect you want update, not insert:



UPDATE ph
SET CUSTOM_DATASETS = bi.Test_Custom_DataSets
FROM [dbo].[PRODUCTION_HISTORY] pn JOIN
[dbo].[BULK_INSERT] bi
ON bi.WELL_KEY = pn.WELL_KEY;





share|improve this answer























  • Thanks it worked!

    – Alex
    Mar 21 at 17:58















0














I suspect you want update, not insert:



UPDATE ph
SET CUSTOM_DATASETS = bi.Test_Custom_DataSets
FROM [dbo].[PRODUCTION_HISTORY] pn JOIN
[dbo].[BULK_INSERT] bi
ON bi.WELL_KEY = pn.WELL_KEY;





share|improve this answer























  • Thanks it worked!

    – Alex
    Mar 21 at 17:58













0












0








0







I suspect you want update, not insert:



UPDATE ph
SET CUSTOM_DATASETS = bi.Test_Custom_DataSets
FROM [dbo].[PRODUCTION_HISTORY] pn JOIN
[dbo].[BULK_INSERT] bi
ON bi.WELL_KEY = pn.WELL_KEY;





share|improve this answer













I suspect you want update, not insert:



UPDATE ph
SET CUSTOM_DATASETS = bi.Test_Custom_DataSets
FROM [dbo].[PRODUCTION_HISTORY] pn JOIN
[dbo].[BULK_INSERT] bi
ON bi.WELL_KEY = pn.WELL_KEY;






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 17:31









Gordon LinoffGordon Linoff

791k35316419




791k35316419












  • Thanks it worked!

    – Alex
    Mar 21 at 17:58

















  • Thanks it worked!

    – Alex
    Mar 21 at 17:58
















Thanks it worked!

– Alex
Mar 21 at 17:58





Thanks it worked!

– Alex
Mar 21 at 17:58

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285116%2finserting-rows-from-one-table-to-another-where-match-occurs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript