Update a set of SQL statements
dbo.MatchFirstName(@FirstName) and dbo.MatchLastName(@LastName)
are table Value Functions(TVFs).
Problem:
In my Update statement i.e Update #Temp
after Insert
, I want only those rows to be updated that were inserted via the Insert statement used just above it i.e In first Update statment, only the rows that were inserted by selecting from TVF dbo.MatchFirstNumber
.
I have my SQL queries like this:
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchFirstName(@FirstName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchLastName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchLastName(@LastName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
It as of now obviously updates all the rows.
Secondly, I tried with the condition where FuncWeight is null
i.e
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal where FuncWeight is null
but surprisingly it results in all 1's in FuncWeight Column. What could be the reason?
What could be the workaround for this problem?
sql-server ssms
bumped to the homepage by Community♦ 1 min ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
dbo.MatchFirstName(@FirstName) and dbo.MatchLastName(@LastName)
are table Value Functions(TVFs).
Problem:
In my Update statement i.e Update #Temp
after Insert
, I want only those rows to be updated that were inserted via the Insert statement used just above it i.e In first Update statment, only the rows that were inserted by selecting from TVF dbo.MatchFirstNumber
.
I have my SQL queries like this:
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchFirstName(@FirstName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchLastName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchLastName(@LastName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
It as of now obviously updates all the rows.
Secondly, I tried with the condition where FuncWeight is null
i.e
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal where FuncWeight is null
but surprisingly it results in all 1's in FuncWeight Column. What could be the reason?
What could be the workaround for this problem?
sql-server ssms
bumped to the homepage by Community♦ 1 min ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Just update those rows where FuncWeight is NULL? Although doing the calculation already when inserting would probably be better from performance point of view.
– James Z
Jan 25 '15 at 13:00
@JamesZ: Thanks. That is exactly what I was trying to do i.e calculate values before inserting and inserting those with that select statement used to insert values above. That part is confusing me.
– Simran kaur
Jan 25 '15 at 13:11
@JameZ: Could you please check the update. The condition FuncWeight is null does not seem to work right in the case :/
– Simran kaur
Jan 25 '15 at 13:26
If the value in the variable is not 1, maybe there's something wrong in your data types.
– James Z
Jan 25 '15 at 13:37
add a comment |
dbo.MatchFirstName(@FirstName) and dbo.MatchLastName(@LastName)
are table Value Functions(TVFs).
Problem:
In my Update statement i.e Update #Temp
after Insert
, I want only those rows to be updated that were inserted via the Insert statement used just above it i.e In first Update statment, only the rows that were inserted by selecting from TVF dbo.MatchFirstNumber
.
I have my SQL queries like this:
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchFirstName(@FirstName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchLastName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchLastName(@LastName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
It as of now obviously updates all the rows.
Secondly, I tried with the condition where FuncWeight is null
i.e
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal where FuncWeight is null
but surprisingly it results in all 1's in FuncWeight Column. What could be the reason?
What could be the workaround for this problem?
sql-server ssms
dbo.MatchFirstName(@FirstName) and dbo.MatchLastName(@LastName)
are table Value Functions(TVFs).
Problem:
In my Update statement i.e Update #Temp
after Insert
, I want only those rows to be updated that were inserted via the Insert statement used just above it i.e In first Update statment, only the rows that were inserted by selecting from TVF dbo.MatchFirstNumber
.
I have my SQL queries like this:
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchFirstName(@FirstName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchLastName'
Insert into #Temp2(Rownumber, ValFromFunc) select RowNumber,PercentMatch from dbo.MatchLastName(@LastName)
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal
select * from #Temp2
It as of now obviously updates all the rows.
Secondly, I tried with the condition where FuncWeight is null
i.e
Update #Temp2 set FuncWeight = @constVal, Percentage = ValFromFunc * @constVal where FuncWeight is null
but surprisingly it results in all 1's in FuncWeight Column. What could be the reason?
What could be the workaround for this problem?
sql-server ssms
sql-server ssms
edited Jan 25 '15 at 13:26
Simran kaur
asked Jan 25 '15 at 12:56
Simran kaurSimran kaur
13628
13628
bumped to the homepage by Community♦ 1 min ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 min ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Just update those rows where FuncWeight is NULL? Although doing the calculation already when inserting would probably be better from performance point of view.
– James Z
Jan 25 '15 at 13:00
@JamesZ: Thanks. That is exactly what I was trying to do i.e calculate values before inserting and inserting those with that select statement used to insert values above. That part is confusing me.
– Simran kaur
Jan 25 '15 at 13:11
@JameZ: Could you please check the update. The condition FuncWeight is null does not seem to work right in the case :/
– Simran kaur
Jan 25 '15 at 13:26
If the value in the variable is not 1, maybe there's something wrong in your data types.
– James Z
Jan 25 '15 at 13:37
add a comment |
Just update those rows where FuncWeight is NULL? Although doing the calculation already when inserting would probably be better from performance point of view.
– James Z
Jan 25 '15 at 13:00
@JamesZ: Thanks. That is exactly what I was trying to do i.e calculate values before inserting and inserting those with that select statement used to insert values above. That part is confusing me.
– Simran kaur
Jan 25 '15 at 13:11
@JameZ: Could you please check the update. The condition FuncWeight is null does not seem to work right in the case :/
– Simran kaur
Jan 25 '15 at 13:26
If the value in the variable is not 1, maybe there's something wrong in your data types.
– James Z
Jan 25 '15 at 13:37
Just update those rows where FuncWeight is NULL? Although doing the calculation already when inserting would probably be better from performance point of view.
– James Z
Jan 25 '15 at 13:00
Just update those rows where FuncWeight is NULL? Although doing the calculation already when inserting would probably be better from performance point of view.
– James Z
Jan 25 '15 at 13:00
@JamesZ: Thanks. That is exactly what I was trying to do i.e calculate values before inserting and inserting those with that select statement used to insert values above. That part is confusing me.
– Simran kaur
Jan 25 '15 at 13:11
@JamesZ: Thanks. That is exactly what I was trying to do i.e calculate values before inserting and inserting those with that select statement used to insert values above. That part is confusing me.
– Simran kaur
Jan 25 '15 at 13:11
@JameZ: Could you please check the update. The condition FuncWeight is null does not seem to work right in the case :/
– Simran kaur
Jan 25 '15 at 13:26
@JameZ: Could you please check the update. The condition FuncWeight is null does not seem to work right in the case :/
– Simran kaur
Jan 25 '15 at 13:26
If the value in the variable is not 1, maybe there's something wrong in your data types.
– James Z
Jan 25 '15 at 13:37
If the value in the variable is not 1, maybe there's something wrong in your data types.
– James Z
Jan 25 '15 at 13:37
add a comment |
1 Answer
1
active
oldest
votes
You don't need an INSERT / UPDATE. These could each be written as a single INSERT that would only have the values you want. E.g.
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName';
INSERT INTO #Temp2(RowNumber, ValFromFun, FuncWeight, percentage)
SELECT RowNumber, PercentMatch, @constVal, PercentMatch * @constVal
from dbo.MatchFirstName(@FirstName)
;
But if you really wanted to capture the output of the INSERT statement, SQL Server supports the OUTPUT clause, which you could dump to another temp table like this:
CREATE TABLE #just_the_ids(some_id int NOT NULL UNIQUE);
INSERT INTO #Temp2(RowNumber, ValFromFun)
OUTPUT INSERTED.RowNumber INTO #just_the_ids
SELECT RowNumber, PercentMatch from dbo.MatchFirstName(@FirstName);
And then you could use #just_the_ids for your second update.
Thank you for your response. I tried your code. The value that I get in constVal variable is just right and what I want. but while trying to insert it into the FuncWeight column of #Temp2 table, it changes to 1. I am really not able to understand what is wrong here. The data type of Func Weight column is float(3) which I have mentioned above.If that is not data type problem what else could it be? Secondly, i would like you to note that function MatchFirstName returns a table that has only 2 fields and those values are being inserted into RowNumber and PercenMatch column of#Temp2(cont.)
– Simran kaur
Jan 27 '15 at 10:56
so are you sure it is possible to insert into table while selecting output of MatchFirstName function and value of constVal variable?
– Simran kaur
Jan 27 '15 at 10:57
In terms of column names, I followed what you showed in your question. If the temp table has a column named PercentMatch, then the values are transposed.
– epic_fil
Jan 27 '15 at 20:19
What data types are the @constVal, FuncWeight column, and PercentMatch from your func?
– epic_fil
Jan 27 '15 at 20:20
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fdba.stackexchange.com%2fquestions%2f90115%2fupdate-a-set-of-sql-statements%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don't need an INSERT / UPDATE. These could each be written as a single INSERT that would only have the values you want. E.g.
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName';
INSERT INTO #Temp2(RowNumber, ValFromFun, FuncWeight, percentage)
SELECT RowNumber, PercentMatch, @constVal, PercentMatch * @constVal
from dbo.MatchFirstName(@FirstName)
;
But if you really wanted to capture the output of the INSERT statement, SQL Server supports the OUTPUT clause, which you could dump to another temp table like this:
CREATE TABLE #just_the_ids(some_id int NOT NULL UNIQUE);
INSERT INTO #Temp2(RowNumber, ValFromFun)
OUTPUT INSERTED.RowNumber INTO #just_the_ids
SELECT RowNumber, PercentMatch from dbo.MatchFirstName(@FirstName);
And then you could use #just_the_ids for your second update.
Thank you for your response. I tried your code. The value that I get in constVal variable is just right and what I want. but while trying to insert it into the FuncWeight column of #Temp2 table, it changes to 1. I am really not able to understand what is wrong here. The data type of Func Weight column is float(3) which I have mentioned above.If that is not data type problem what else could it be? Secondly, i would like you to note that function MatchFirstName returns a table that has only 2 fields and those values are being inserted into RowNumber and PercenMatch column of#Temp2(cont.)
– Simran kaur
Jan 27 '15 at 10:56
so are you sure it is possible to insert into table while selecting output of MatchFirstName function and value of constVal variable?
– Simran kaur
Jan 27 '15 at 10:57
In terms of column names, I followed what you showed in your question. If the temp table has a column named PercentMatch, then the values are transposed.
– epic_fil
Jan 27 '15 at 20:19
What data types are the @constVal, FuncWeight column, and PercentMatch from your func?
– epic_fil
Jan 27 '15 at 20:20
add a comment |
You don't need an INSERT / UPDATE. These could each be written as a single INSERT that would only have the values you want. E.g.
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName';
INSERT INTO #Temp2(RowNumber, ValFromFun, FuncWeight, percentage)
SELECT RowNumber, PercentMatch, @constVal, PercentMatch * @constVal
from dbo.MatchFirstName(@FirstName)
;
But if you really wanted to capture the output of the INSERT statement, SQL Server supports the OUTPUT clause, which you could dump to another temp table like this:
CREATE TABLE #just_the_ids(some_id int NOT NULL UNIQUE);
INSERT INTO #Temp2(RowNumber, ValFromFun)
OUTPUT INSERTED.RowNumber INTO #just_the_ids
SELECT RowNumber, PercentMatch from dbo.MatchFirstName(@FirstName);
And then you could use #just_the_ids for your second update.
Thank you for your response. I tried your code. The value that I get in constVal variable is just right and what I want. but while trying to insert it into the FuncWeight column of #Temp2 table, it changes to 1. I am really not able to understand what is wrong here. The data type of Func Weight column is float(3) which I have mentioned above.If that is not data type problem what else could it be? Secondly, i would like you to note that function MatchFirstName returns a table that has only 2 fields and those values are being inserted into RowNumber and PercenMatch column of#Temp2(cont.)
– Simran kaur
Jan 27 '15 at 10:56
so are you sure it is possible to insert into table while selecting output of MatchFirstName function and value of constVal variable?
– Simran kaur
Jan 27 '15 at 10:57
In terms of column names, I followed what you showed in your question. If the temp table has a column named PercentMatch, then the values are transposed.
– epic_fil
Jan 27 '15 at 20:19
What data types are the @constVal, FuncWeight column, and PercentMatch from your func?
– epic_fil
Jan 27 '15 at 20:20
add a comment |
You don't need an INSERT / UPDATE. These could each be written as a single INSERT that would only have the values you want. E.g.
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName';
INSERT INTO #Temp2(RowNumber, ValFromFun, FuncWeight, percentage)
SELECT RowNumber, PercentMatch, @constVal, PercentMatch * @constVal
from dbo.MatchFirstName(@FirstName)
;
But if you really wanted to capture the output of the INSERT statement, SQL Server supports the OUTPUT clause, which you could dump to another temp table like this:
CREATE TABLE #just_the_ids(some_id int NOT NULL UNIQUE);
INSERT INTO #Temp2(RowNumber, ValFromFun)
OUTPUT INSERTED.RowNumber INTO #just_the_ids
SELECT RowNumber, PercentMatch from dbo.MatchFirstName(@FirstName);
And then you could use #just_the_ids for your second update.
You don't need an INSERT / UPDATE. These could each be written as a single INSERT that would only have the values you want. E.g.
select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = 'MatchFirstName';
INSERT INTO #Temp2(RowNumber, ValFromFun, FuncWeight, percentage)
SELECT RowNumber, PercentMatch, @constVal, PercentMatch * @constVal
from dbo.MatchFirstName(@FirstName)
;
But if you really wanted to capture the output of the INSERT statement, SQL Server supports the OUTPUT clause, which you could dump to another temp table like this:
CREATE TABLE #just_the_ids(some_id int NOT NULL UNIQUE);
INSERT INTO #Temp2(RowNumber, ValFromFun)
OUTPUT INSERTED.RowNumber INTO #just_the_ids
SELECT RowNumber, PercentMatch from dbo.MatchFirstName(@FirstName);
And then you could use #just_the_ids for your second update.
answered Jan 26 '15 at 17:36
epic_filepic_fil
28317
28317
Thank you for your response. I tried your code. The value that I get in constVal variable is just right and what I want. but while trying to insert it into the FuncWeight column of #Temp2 table, it changes to 1. I am really not able to understand what is wrong here. The data type of Func Weight column is float(3) which I have mentioned above.If that is not data type problem what else could it be? Secondly, i would like you to note that function MatchFirstName returns a table that has only 2 fields and those values are being inserted into RowNumber and PercenMatch column of#Temp2(cont.)
– Simran kaur
Jan 27 '15 at 10:56
so are you sure it is possible to insert into table while selecting output of MatchFirstName function and value of constVal variable?
– Simran kaur
Jan 27 '15 at 10:57
In terms of column names, I followed what you showed in your question. If the temp table has a column named PercentMatch, then the values are transposed.
– epic_fil
Jan 27 '15 at 20:19
What data types are the @constVal, FuncWeight column, and PercentMatch from your func?
– epic_fil
Jan 27 '15 at 20:20
add a comment |
Thank you for your response. I tried your code. The value that I get in constVal variable is just right and what I want. but while trying to insert it into the FuncWeight column of #Temp2 table, it changes to 1. I am really not able to understand what is wrong here. The data type of Func Weight column is float(3) which I have mentioned above.If that is not data type problem what else could it be? Secondly, i would like you to note that function MatchFirstName returns a table that has only 2 fields and those values are being inserted into RowNumber and PercenMatch column of#Temp2(cont.)
– Simran kaur
Jan 27 '15 at 10:56
so are you sure it is possible to insert into table while selecting output of MatchFirstName function and value of constVal variable?
– Simran kaur
Jan 27 '15 at 10:57
In terms of column names, I followed what you showed in your question. If the temp table has a column named PercentMatch, then the values are transposed.
– epic_fil
Jan 27 '15 at 20:19
What data types are the @constVal, FuncWeight column, and PercentMatch from your func?
– epic_fil
Jan 27 '15 at 20:20
Thank you for your response. I tried your code. The value that I get in constVal variable is just right and what I want. but while trying to insert it into the FuncWeight column of #Temp2 table, it changes to 1. I am really not able to understand what is wrong here. The data type of Func Weight column is float(3) which I have mentioned above.If that is not data type problem what else could it be? Secondly, i would like you to note that function MatchFirstName returns a table that has only 2 fields and those values are being inserted into RowNumber and PercenMatch column of#Temp2(cont.)
– Simran kaur
Jan 27 '15 at 10:56
Thank you for your response. I tried your code. The value that I get in constVal variable is just right and what I want. but while trying to insert it into the FuncWeight column of #Temp2 table, it changes to 1. I am really not able to understand what is wrong here. The data type of Func Weight column is float(3) which I have mentioned above.If that is not data type problem what else could it be? Secondly, i would like you to note that function MatchFirstName returns a table that has only 2 fields and those values are being inserted into RowNumber and PercenMatch column of#Temp2(cont.)
– Simran kaur
Jan 27 '15 at 10:56
so are you sure it is possible to insert into table while selecting output of MatchFirstName function and value of constVal variable?
– Simran kaur
Jan 27 '15 at 10:57
so are you sure it is possible to insert into table while selecting output of MatchFirstName function and value of constVal variable?
– Simran kaur
Jan 27 '15 at 10:57
In terms of column names, I followed what you showed in your question. If the temp table has a column named PercentMatch, then the values are transposed.
– epic_fil
Jan 27 '15 at 20:19
In terms of column names, I followed what you showed in your question. If the temp table has a column named PercentMatch, then the values are transposed.
– epic_fil
Jan 27 '15 at 20:19
What data types are the @constVal, FuncWeight column, and PercentMatch from your func?
– epic_fil
Jan 27 '15 at 20:20
What data types are the @constVal, FuncWeight column, and PercentMatch from your func?
– epic_fil
Jan 27 '15 at 20:20
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- 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%2fdba.stackexchange.com%2fquestions%2f90115%2fupdate-a-set-of-sql-statements%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
Just update those rows where FuncWeight is NULL? Although doing the calculation already when inserting would probably be better from performance point of view.
– James Z
Jan 25 '15 at 13:00
@JamesZ: Thanks. That is exactly what I was trying to do i.e calculate values before inserting and inserting those with that select statement used to insert values above. That part is confusing me.
– Simran kaur
Jan 25 '15 at 13:11
@JameZ: Could you please check the update. The condition FuncWeight is null does not seem to work right in the case :/
– Simran kaur
Jan 25 '15 at 13:26
If the value in the variable is not 1, maybe there's something wrong in your data types.
– James Z
Jan 25 '15 at 13:37