Change specific data based on condition
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
Product consist of at least 1 or more articles. Nummer consist of 3-parts separated by dots (always). The one which always appears is always with .1 at the end (main article). For all articles belongs to product their vater is always the main article.
Example product consist of main article and additionally with combinations
Nummer Vater
12.1001.1 (main article) 12.1001.1
12.1001.2 (combination) 12.1001.1
12.1001.8L (combination) 12.1001.1
Example of 3 products below:
Nummer Vater
12.1001.1 12.1001.1
12.1001.2L 12.1001.1
03.999.1 03.999.1
12.1001.10R 12.1001.1
03.999.3 03.999.1
786.2892.1 786.2892.1
786.2892.4 786.2892.1
I want to give user possibility to select one article (main article) and change second part of it. The change should be reflected to entire product articles and their vaters. According to our example let's assume user wants to change article:
03.999.1
999 --> 1001
this means at the end only those records should be changed as below:
03.1001.1 03.1001.1
03.1001.3 03.1001.1
My current sql presents like this and seems its working. Could you tell me whether it's really fine and do not ovverwrite something else?:
Values i pass to query are:
oldNummer = 03.999.1
newNummer = 03.1001.1
oldNummerWithout1 = 03.999.
newNummerWithout1 = 03.1001.
UPDATE temp SET Nummer = replace(Nummer, @oldNummerWithout1, @newNummerWithout1), Vater = replace(Vater, @oldNummer, @newNummer)
WHERE Vater = @oldNummer", transaction.Connection)
Have lot products in db and want to be sure this is really just enough. Awaiting your feedback as an answer.
sql sql-server
add a comment |Â
up vote
0
down vote
favorite
Product consist of at least 1 or more articles. Nummer consist of 3-parts separated by dots (always). The one which always appears is always with .1 at the end (main article). For all articles belongs to product their vater is always the main article.
Example product consist of main article and additionally with combinations
Nummer Vater
12.1001.1 (main article) 12.1001.1
12.1001.2 (combination) 12.1001.1
12.1001.8L (combination) 12.1001.1
Example of 3 products below:
Nummer Vater
12.1001.1 12.1001.1
12.1001.2L 12.1001.1
03.999.1 03.999.1
12.1001.10R 12.1001.1
03.999.3 03.999.1
786.2892.1 786.2892.1
786.2892.4 786.2892.1
I want to give user possibility to select one article (main article) and change second part of it. The change should be reflected to entire product articles and their vaters. According to our example let's assume user wants to change article:
03.999.1
999 --> 1001
this means at the end only those records should be changed as below:
03.1001.1 03.1001.1
03.1001.3 03.1001.1
My current sql presents like this and seems its working. Could you tell me whether it's really fine and do not ovverwrite something else?:
Values i pass to query are:
oldNummer = 03.999.1
newNummer = 03.1001.1
oldNummerWithout1 = 03.999.
newNummerWithout1 = 03.1001.
UPDATE temp SET Nummer = replace(Nummer, @oldNummerWithout1, @newNummerWithout1), Vater = replace(Vater, @oldNummer, @newNummer)
WHERE Vater = @oldNummer", transaction.Connection)
Have lot products in db and want to be sure this is really just enough. Awaiting your feedback as an answer.
sql sql-server
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Product consist of at least 1 or more articles. Nummer consist of 3-parts separated by dots (always). The one which always appears is always with .1 at the end (main article). For all articles belongs to product their vater is always the main article.
Example product consist of main article and additionally with combinations
Nummer Vater
12.1001.1 (main article) 12.1001.1
12.1001.2 (combination) 12.1001.1
12.1001.8L (combination) 12.1001.1
Example of 3 products below:
Nummer Vater
12.1001.1 12.1001.1
12.1001.2L 12.1001.1
03.999.1 03.999.1
12.1001.10R 12.1001.1
03.999.3 03.999.1
786.2892.1 786.2892.1
786.2892.4 786.2892.1
I want to give user possibility to select one article (main article) and change second part of it. The change should be reflected to entire product articles and their vaters. According to our example let's assume user wants to change article:
03.999.1
999 --> 1001
this means at the end only those records should be changed as below:
03.1001.1 03.1001.1
03.1001.3 03.1001.1
My current sql presents like this and seems its working. Could you tell me whether it's really fine and do not ovverwrite something else?:
Values i pass to query are:
oldNummer = 03.999.1
newNummer = 03.1001.1
oldNummerWithout1 = 03.999.
newNummerWithout1 = 03.1001.
UPDATE temp SET Nummer = replace(Nummer, @oldNummerWithout1, @newNummerWithout1), Vater = replace(Vater, @oldNummer, @newNummer)
WHERE Vater = @oldNummer", transaction.Connection)
Have lot products in db and want to be sure this is really just enough. Awaiting your feedback as an answer.
sql sql-server
Product consist of at least 1 or more articles. Nummer consist of 3-parts separated by dots (always). The one which always appears is always with .1 at the end (main article). For all articles belongs to product their vater is always the main article.
Example product consist of main article and additionally with combinations
Nummer Vater
12.1001.1 (main article) 12.1001.1
12.1001.2 (combination) 12.1001.1
12.1001.8L (combination) 12.1001.1
Example of 3 products below:
Nummer Vater
12.1001.1 12.1001.1
12.1001.2L 12.1001.1
03.999.1 03.999.1
12.1001.10R 12.1001.1
03.999.3 03.999.1
786.2892.1 786.2892.1
786.2892.4 786.2892.1
I want to give user possibility to select one article (main article) and change second part of it. The change should be reflected to entire product articles and their vaters. According to our example let's assume user wants to change article:
03.999.1
999 --> 1001
this means at the end only those records should be changed as below:
03.1001.1 03.1001.1
03.1001.3 03.1001.1
My current sql presents like this and seems its working. Could you tell me whether it's really fine and do not ovverwrite something else?:
Values i pass to query are:
oldNummer = 03.999.1
newNummer = 03.1001.1
oldNummerWithout1 = 03.999.
newNummerWithout1 = 03.1001.
UPDATE temp SET Nummer = replace(Nummer, @oldNummerWithout1, @newNummerWithout1), Vater = replace(Vater, @oldNummer, @newNummer)
WHERE Vater = @oldNummer", transaction.Connection)
Have lot products in db and want to be sure this is really just enough. Awaiting your feedback as an answer.
sql sql-server
asked Jan 25 at 21:25
Arie
1134
1134
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186004%2fchange-specific-data-based-on-condition%23new-answer', 'question_page');
);
Post as a guest
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
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
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