sql - Same code executed on different servers (same version) yields different results -


issue delphi legacy code. added 1 line of code correct 1 error , created new error.

new error causing same executable yield different results on different servers(switched pointer dev prod environment on executable).

code:

sescapedstring:=stringreplace(sstringin,'[','''+char(27)+''[',[rfreplaceall]); sescapedstring:=stringreplace(sescapedstring,']','''+char(27)+'']',[rfreplaceall]); sescapedstring:=stringreplace(sescapedstring,'''','''''',[rfreplaceall]);// line created new  bug result:=' ''' + trim(sescapedstring) + '%'''+'  escape char(27) '; 

when running code against dev query finds objects characters '[' , ']' in against prod query not find items:

the first thing checked data: identical in both cases second thing checked sql server versions (11.0.3128 on both servers) third thing checking settings on servers: dbcc useroptions; -- same on both select name, collation_name sys.databases -- same on both select @@options -- same on both. quoted identifiers 'on' both servers

it comes down fact know 1 server treating escape character (chr(27)) differently other knot know why.

does have theory(or answer) why 2 similar servers treating escape characters differently?

the goal here getting prod server return values '[' , ']', setting system work legacy code take lot of additional time. have fix code

sescapedstring:=stringreplace(sstringin,'[','[[]',[rfreplaceall]); 

but faster option seem getting server read values same.

update: found root cause of difference , more mundane expected, turns out query running executed twice. second execution missing key piece on production server. issue resolved moving new line of code executed first rather last.

i first try find out if sql causes different behaviour when sent application: sending sql interactive sql client tool both servers.

to make sure manually tested sql same in application, try log or capture exact sql sent application text file , paste content sql client tool.

if server culprit, using sql different client tool should cause same difference 2 servers. if client tool shows same (correct) result on both servers, going on in delphi application.

p.s. upvoted, interesting phenomenon


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -