Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SP - output confusion?


SP - output confusion?

Author
Message
durai nagarajan
durai nagarajan
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1107 Visits: 2771
Hello,

we have a SP which in turn calls 2 sp's.

because of one sp output data got updated wrongly .

but when i run the sp with necessary paratmeters it is giving proper output.

Note: that SP is not giving wrong output every time.

any suggestions?

Regards
Durai Nagarajan
sanket kokane
sanket kokane
Old Hand
Old Hand (331 reputation)Old Hand (331 reputation)Old Hand (331 reputation)Old Hand (331 reputation)Old Hand (331 reputation)Old Hand (331 reputation)Old Hand (331 reputation)Old Hand (331 reputation)

Group: General Forum Members
Points: 331 Visits: 1019
As long as its running successfully,it should not give wrong output.


Just curious,did you used NOLOCK hint anywhere inside SP ?

-----------------------------------------------------------------------------
संकेत कोकणे
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
durai nagarajan (11/16/2012)
Note: that SP is not giving wrong output every time.
Here do you mean that with same parameters you are getting different results (sometime right sometmes wrong ) ? any inbult function like getdate() OR RAND() fuunction used inside ?

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
durai nagarajan
durai nagarajan
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1107 Visits: 2771
Nolock is not used.

we havent used inbuilt function also.

there is date conversion and comparison between a table column and input parameters.

i forgot to mention it is compared with a encypted column also.

anu suggestion based on above details.

Regards
Durai Nagarajan
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
durai nagarajan (11/19/2012)
Nolock is not used.

we havent used inbuilt function also.

there is date conversion and comparison between a table column and input parameters.

i forgot to mention it is compared with a encypted column also.

anu suggestion based on above details.

can you post the Sp definition here ?

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
durai nagarajan
durai nagarajan
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1107 Visits: 2771

ALTER PROCEDURE SP_Name
( @empCode VARCHAR(10), @date DATETIME )
with encryption
AS
BEGIN
open symmetrickey code part

SELECT dbo.Decrypt(EmpCode), dbo.Decrypt(EmpName),
CASE LeaveType WHEN 'ON DUTY' THEN 'OD'
WHEN 'Paternity' THEN 'CL'
WHEN 'Absconding' THEN 'A'
WHEN 'Breav' THEN 'CL'
ELSE LeaveType
END, CONVERT(VARCHAR, @date, 101), LeaveStatus FROM Leave_Details
WHERE CONVERT(DATETIME, CONVERT(VARCHAR, @date, 101)) BETWEEN FromDate AND ToDate
AND LeaveRequestStatus = 'Authorize'
AND dbo.Decrypt(EmpCode) = @empCode

END



this is the code after masking.

Regards
Durai Nagarajan
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
durai nagarajan (11/19/2012)
WHERE CONVERT(DATETIME, CONVERT(VARCHAR, @date, 101)) BETWEEN FromDate AND ToDate
this is the code which is creating problem as its not using the index for search (if any ) , better to make the passed parameters according to the column compatible data. see this http://www.sqlusa.com/bestpractices/substring/

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
durai nagarajan
durai nagarajan
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1107 Visits: 2771
thanks, will check

just a doubt this will have to slow down my query why my output has to vary?

Regards
Durai Nagarajan
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
durai nagarajan (11/19/2012)
thanks, will check

just a doubt this will have to slow down my query why my output has to vary?

your parameter to this sp is @date / So are you giving same values whenever u are getting different output ?

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
durai nagarajan
durai nagarajan
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1107 Visits: 2771
No, for some empcode and date combination the output is right for some it is wrong.

Regards
Durai Nagarajan
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search