SSMS / Server Import and Export Wizard - which screen allow me to update the data during export
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
add a comment |
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
Don't useSELECT *
and specify the columns explicitly. Also, use aCASE
statement for the column that does allowNULL
andWHEN col IS NULL THEN <value>
. There isISNULL()
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 theUPDATE
statements.
– Pimp Juice IT
Feb 2 at 4:53
add a comment |
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
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
sql-server ssms
asked Feb 2 at 4:04
whalonwhalon
1
1
Don't useSELECT *
and specify the columns explicitly. Also, use aCASE
statement for the column that does allowNULL
andWHEN col IS NULL THEN <value>
. There isISNULL()
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 theUPDATE
statements.
– Pimp Juice IT
Feb 2 at 4:53
add a comment |
Don't useSELECT *
and specify the columns explicitly. Also, use aCASE
statement for the column that does allowNULL
andWHEN col IS NULL THEN <value>
. There isISNULL()
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 theUPDATE
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
add a comment |
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
});
}
});
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%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
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.
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%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
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
Don't use
SELECT *
and specify the columns explicitly. Also, use aCASE
statement for the column that does allowNULL
andWHEN col IS NULL THEN <value>
. There isISNULL()
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 theUPDATE
statements.– Pimp Juice IT
Feb 2 at 4:53