Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1279

Re: Need help in SQL query

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Need help in SQL query
Date 2012-09-11 23:24 +0200
Organization Erland Sommarskog
Message-ID <XnsA0CBEE157DFF7Yazorman@127.0.0.1> (permalink)
References <9c4cab96-dd12-4947-94ff-f1ed31b2baee@googlegroups.com>

Show all headers | View raw


Dinesh (dinesht15@gmail.com) writes:
> But when I am executing the SP it is not returning the correct number of
> name chnages. I have chnaged first name from Niki to Nikki and then
> Nikki to Nikk and Nikk to Niki... Vijay to Sunny and Sunny to Niki. 
> 
> But here Sunny to Niki change is not appearing in my query result. It is
> returning Niki to Niki as unchnaged row, which is not correct. 

Given the complexity of the code, are you surprised?

Why is it using dynamic SQL in the first place? On a quick look of the
procedure, I could see no reason for this. And if ou need to use dynamic
SQL, why do you use unparameterised dynamic SQL?

I have no time to dig into you query for the moment, but I would recommend
that you remove the dynamic SQL, and then clean up the query so that it's
easier to read. (Less uppercase could help too.) Maybe the error will be
apparent as you work with the reformatting.


-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Need help in SQL query Dinesh <dinesht15@gmail.com> - 2012-09-11 06:41 -0700
  Re: Need help in SQL query Erland Sommarskog <esquel@sommarskog.se> - 2012-09-11 23:24 +0200
  Re: Need help in SQL query Bal Govind <balgovindjss@gmail.com> - 2014-03-11 05:27 -0700

csiph-web