Math expression as Column value as string in the Dynamic Sql
-
Hi all, I am passing column names in dynamic sql like 'col1, col2, col3' + ', ''' + @reportId + '''', up to col3 all the columns are giving correct values, but the @reportId is a string which has value as '1-085' that's being converted into integers and giving me the value '-084'. I mean may its calculating the expression and returning the resultant value. But I want that string to be as it is, means I want that value as '1-085' instead of a calculated value ie -84, is there anyway to do it. Any help would be greatly helpful, thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
-
Hi all, I am passing column names in dynamic sql like 'col1, col2, col3' + ', ''' + @reportId + '''', up to col3 all the columns are giving correct values, but the @reportId is a string which has value as '1-085' that's being converted into integers and giving me the value '-084'. I mean may its calculating the expression and returning the resultant value. But I want that string to be as it is, means I want that value as '1-085' instead of a calculated value ie -84, is there anyway to do it. Any help would be greatly helpful, thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
-
If it is a string then it will be saved as a string. Your code must be doing something strange.
No I am passing it as a string only from an ssis package variable which is of type string, I am appending both these strings as 'col1, col2, col3' + ', ''' + @reportId + '''' and passing it as nvarchar parameter into a stored procedure Exec [ETL].[PopulateStageTable] ?, ?, ?, ?, ?, ?, ? There are other Parameters but they are not giving any problem excel this, I checked even the execute sql too has this parameter defined as nvarchar and same thing in the Stored procedure too, nothing is converted to number or anything like that Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
-
No I am passing it as a string only from an ssis package variable which is of type string, I am appending both these strings as 'col1, col2, col3' + ', ''' + @reportId + '''' and passing it as nvarchar parameter into a stored procedure Exec [ETL].[PopulateStageTable] ?, ?, ?, ?, ?, ?, ? There are other Parameters but they are not giving any problem excel this, I checked even the execute sql too has this parameter defined as nvarchar and same thing in the Stored procedure too, nothing is converted to number or anything like that Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
Rephrasing what the previous response was suggesting (I believe.) You posted a line where @reportId is used. Nothing in that line would change the value of that. That line has nothing to do with the value in @reportId. At that point it already has the value you are seeing. Consequently you are doing something before that which causes it to have that value. You need to find that and correct it.
-
Rephrasing what the previous response was suggesting (I believe.) You posted a line where @reportId is used. Nothing in that line would change the value of that. That line has nothing to do with the value in @reportId. At that point it already has the value you are seeing. Consequently you are doing something before that which causes it to have that value. You need to find that and correct it.
-
Rephrasing what the previous response was suggesting (I believe.) You posted a line where @reportId is used. Nothing in that line would change the value of that. That line has nothing to do with the value in @reportId. At that point it already has the value you are seeing. Consequently you are doing something before that which causes it to have that value. You need to find that and correct it.
I didn't quite get your answer, but some how its deducting the value and putting it there. If you can answer that's fine, but you are not able that's fine I just added one more step in Control flow which updates that Column with the correct value. But if you know it would be helpful for me. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
-
I didn't quite get your answer, but some how its deducting the value and putting it there. If you can answer that's fine, but you are not able that's fine I just added one more step in Control flow which updates that Column with the correct value. But if you know it would be helpful for me. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
indian143 wrote:
but some how its deducting the value
Computers are deterministic. They do what they do because some code explicitly to do it that way. Not sure how I can make it clearer. If you go to the store and open your wallet and expect it to have $20 and it doesn't do you continue to look at the wallet expecting the $20 to show up. Or do you think back where you were before the store to figure out where that money went? Same thing it true for this code. You posted a line where you use the reportId variable. At that point it already had a value. The computer doesn't give it a value at that point, because it already had one. There is code before that line that gives it a value. You must find that code, not the code that you are looking at (again the code you posted) and then figure out from that why it has the value that it does.
-
indian143 wrote:
but some how its deducting the value
Computers are deterministic. They do what they do because some code explicitly to do it that way. Not sure how I can make it clearer. If you go to the store and open your wallet and expect it to have $20 and it doesn't do you continue to look at the wallet expecting the $20 to show up. Or do you think back where you were before the store to figure out where that money went? Same thing it true for this code. You posted a line where you use the reportId variable. At that point it already had a value. The computer doesn't give it a value at that point, because it already had one. There is code before that line that gives it a value. You must find that code, not the code that you are looking at (again the code you posted) and then figure out from that why it has the value that it does.