August 22, 2012 at 11:55 pm
Hi I would like to knw what is the differnce between executing both the update statement.
when i execute the first update statment inside while loop, for one set of record target colum doesnt update the value. but with the second update statement all the records updated sucessfully. I am confused why it had happend?? any help on this??
UPDATE SCHEMAMANLOG.TRNMETRICSSETUPMETRICSDIMENSIONS
SET Target = @NEWGOAL
where SetupDetailsId in (select SetupDetailsId from SCHEMAMANLOG.TrnMetricsSetupDetails where SetupId= @SETUPID )
AND DimensionValueId=@DIMENSIONVALUE
AND SetupDetailsId= @SETUPDET
set @Query = 'UPDATE SCHEMAMANLOG.TRNMETRICSSETUPMETRICSDIMENSIONS
SET Target = ' + CAST( @NEWGOAL AS VARCHAR(10)) +'
where SetupDetailsId in (select SetupDetailsId from SCHEMAMANLOG.TrnMetricsSetupDetails where SetupId=' + CAST( @SETUPID AS VARCHAR(10)) +')
AND DimensionValueId=' + CAST( @DIMENSIONVALUE AS VARCHAR(10)) +'
AND SetupDetailsId=' + CAST( @SETUPDET AS VARCHAR(10)) +''
exec(@Query)
August 23, 2012 at 12:28 am
Both queries look the same to me ...
Except for the cast clauses used with the second one !
Are you sure your @varriable-content isn't longer than 10 characters ?
where SetupDetailsId in (select SetupDetailsId
from SCHEMAMANLOG.TrnMetricsSetupDetails
where SetupId=' + CAST(@SETUPID AS VARCHAR(10)) + ')
AND DimensionValueId=' + CAST(@DIMENSIONVALUE AS VARCHAR(10)) + '
AND SetupDetailsId=' + CAST(@SETUPDET AS VARCHAR(10)) + ''
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
August 23, 2012 at 2:30 am
Yes I am passing only value to this
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply