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?
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
add a comment |
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
1
Use a join in your select statement.
– Sean Lange
Mar 21 at 16:35
I don't see tabledbo.PRODUCTION_HISTORY
in your query.
– Eric
Mar 21 at 16:54
add a comment |
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
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
sql sql-server tsql bulkinsert
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 tabledbo.PRODUCTION_HISTORY
in your query.
– Eric
Mar 21 at 16:54
add a comment |
1
Use a join in your select statement.
– Sean Lange
Mar 21 at 16:35
I don't see tabledbo.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
add a comment |
2 Answers
2
active
oldest
votes
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
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
add a comment |
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;
Thanks it worked!
– Alex
Mar 21 at 17:58
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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;
Thanks it worked!
– Alex
Mar 21 at 17:58
add a comment |
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;
Thanks it worked!
– Alex
Mar 21 at 17:58
add a comment |
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;
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;
answered Mar 21 at 17:31
Gordon LinoffGordon Linoff
791k35316419
791k35316419
Thanks it worked!
– Alex
Mar 21 at 17:58
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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