SSMS / Server Import and Export Wizard - which screen allow me to update the data during export












0















I am using SQL Server Management Studio 2016 to export data between databases. In particular, this time, i am using the option to "write a query to specify the data to transfer", but as part of this process, i want to modify the data being exported. --- the goal being to satisfy a null -> not null situation. A column in my source table is set to allow nulls, and the destination table column will not allow nulls. I cannot change the destination table/drop/recreate it, so i want to script in a defult value any place the target column is NULL.



Starting from the screen with option to "write a query to specify the data to transfer", I am using a standard SELECT * FROM [source table]



Next, in the "Select Source Tables and Views", i browse to edit mappings, so I can then "edit sql" and modify the code that is generating my destination table.



When i click "Edit SQL", i get the syntax for the table of my select statement. Is this where I would construct an update statement?



The Create Table SQL Statement has the syntax CREATE TABLE [dbo].[Query]([Column 1]nvarchar(50) NOT NULL



I want to add an update statement to accomplish this logic: UPDATE TABLE [dbo].[Query] SET [Column 1] = 'default value' WHERE [Column 1] IS NULL



Is this the right place in the import/export wizard to do this? i would greatly appreciate a suggestion or two.



Thanks,
whalen










share|improve this question























  • Don't use SELECT * and specify the columns explicitly. Also, use a CASE statement for the column that does allow NULL and WHEN col IS NULL THEN <value>. There is ISNULL() function too. Make the select statement bring back the expected results for what you need to import without anything further being needed. Get your query in order and get the expected result, then simply run the UPDATE statements.

    – Pimp Juice IT
    Feb 2 at 4:53


















0















I am using SQL Server Management Studio 2016 to export data between databases. In particular, this time, i am using the option to "write a query to specify the data to transfer", but as part of this process, i want to modify the data being exported. --- the goal being to satisfy a null -> not null situation. A column in my source table is set to allow nulls, and the destination table column will not allow nulls. I cannot change the destination table/drop/recreate it, so i want to script in a defult value any place the target column is NULL.



Starting from the screen with option to "write a query to specify the data to transfer", I am using a standard SELECT * FROM [source table]



Next, in the "Select Source Tables and Views", i browse to edit mappings, so I can then "edit sql" and modify the code that is generating my destination table.



When i click "Edit SQL", i get the syntax for the table of my select statement. Is this where I would construct an update statement?



The Create Table SQL Statement has the syntax CREATE TABLE [dbo].[Query]([Column 1]nvarchar(50) NOT NULL



I want to add an update statement to accomplish this logic: UPDATE TABLE [dbo].[Query] SET [Column 1] = 'default value' WHERE [Column 1] IS NULL



Is this the right place in the import/export wizard to do this? i would greatly appreciate a suggestion or two.



Thanks,
whalen










share|improve this question























  • Don't use SELECT * and specify the columns explicitly. Also, use a CASE statement for the column that does allow NULL and WHEN col IS NULL THEN <value>. There is ISNULL() function too. Make the select statement bring back the expected results for what you need to import without anything further being needed. Get your query in order and get the expected result, then simply run the UPDATE statements.

    – Pimp Juice IT
    Feb 2 at 4:53
















0












0








0








I am using SQL Server Management Studio 2016 to export data between databases. In particular, this time, i am using the option to "write a query to specify the data to transfer", but as part of this process, i want to modify the data being exported. --- the goal being to satisfy a null -> not null situation. A column in my source table is set to allow nulls, and the destination table column will not allow nulls. I cannot change the destination table/drop/recreate it, so i want to script in a defult value any place the target column is NULL.



Starting from the screen with option to "write a query to specify the data to transfer", I am using a standard SELECT * FROM [source table]



Next, in the "Select Source Tables and Views", i browse to edit mappings, so I can then "edit sql" and modify the code that is generating my destination table.



When i click "Edit SQL", i get the syntax for the table of my select statement. Is this where I would construct an update statement?



The Create Table SQL Statement has the syntax CREATE TABLE [dbo].[Query]([Column 1]nvarchar(50) NOT NULL



I want to add an update statement to accomplish this logic: UPDATE TABLE [dbo].[Query] SET [Column 1] = 'default value' WHERE [Column 1] IS NULL



Is this the right place in the import/export wizard to do this? i would greatly appreciate a suggestion or two.



Thanks,
whalen










share|improve this question














I am using SQL Server Management Studio 2016 to export data between databases. In particular, this time, i am using the option to "write a query to specify the data to transfer", but as part of this process, i want to modify the data being exported. --- the goal being to satisfy a null -> not null situation. A column in my source table is set to allow nulls, and the destination table column will not allow nulls. I cannot change the destination table/drop/recreate it, so i want to script in a defult value any place the target column is NULL.



Starting from the screen with option to "write a query to specify the data to transfer", I am using a standard SELECT * FROM [source table]



Next, in the "Select Source Tables and Views", i browse to edit mappings, so I can then "edit sql" and modify the code that is generating my destination table.



When i click "Edit SQL", i get the syntax for the table of my select statement. Is this where I would construct an update statement?



The Create Table SQL Statement has the syntax CREATE TABLE [dbo].[Query]([Column 1]nvarchar(50) NOT NULL



I want to add an update statement to accomplish this logic: UPDATE TABLE [dbo].[Query] SET [Column 1] = 'default value' WHERE [Column 1] IS NULL



Is this the right place in the import/export wizard to do this? i would greatly appreciate a suggestion or two.



Thanks,
whalen







sql-server ssms






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 2 at 4:04









whalonwhalon

1




1













  • Don't use SELECT * and specify the columns explicitly. Also, use a CASE statement for the column that does allow NULL and WHEN col IS NULL THEN <value>. There is ISNULL() function too. Make the select statement bring back the expected results for what you need to import without anything further being needed. Get your query in order and get the expected result, then simply run the UPDATE statements.

    – Pimp Juice IT
    Feb 2 at 4:53





















  • Don't use SELECT * and specify the columns explicitly. Also, use a CASE statement for the column that does allow NULL and WHEN col IS NULL THEN <value>. There is ISNULL() function too. Make the select statement bring back the expected results for what you need to import without anything further being needed. Get your query in order and get the expected result, then simply run the UPDATE statements.

    – Pimp Juice IT
    Feb 2 at 4:53



















Don't use SELECT * and specify the columns explicitly. Also, use a CASE statement for the column that does allow NULL and WHEN col IS NULL THEN <value>. There is ISNULL() function too. Make the select statement bring back the expected results for what you need to import without anything further being needed. Get your query in order and get the expected result, then simply run the UPDATE statements.

– Pimp Juice IT
Feb 2 at 4:53







Don't use SELECT * and specify the columns explicitly. Also, use a CASE statement for the column that does allow NULL and WHEN col IS NULL THEN <value>. There is ISNULL() function too. Make the select statement bring back the expected results for what you need to import without anything further being needed. Get your query in order and get the expected result, then simply run the UPDATE statements.

– Pimp Juice IT
Feb 2 at 4:53












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1401226%2fssms-server-import-and-export-wizard-which-screen-allow-me-to-update-the-dat%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • 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%2fsuperuser.com%2fquestions%2f1401226%2fssms-server-import-and-export-wizard-which-screen-allow-me-to-update-the-dat%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

How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

is 'sed' thread safe

How to make a Squid Proxy server?