Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

SP - output confusion? Expand / Collapse
Author
Message
Posted Friday, November 16, 2012 8:15 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:05 AM
Points: 1,058, Visits: 2,697
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
Post #1385724
Posted Friday, November 16, 2012 11:33 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, November 21, 2014 8:48 AM
Points: 323, Visits: 986
As long as its running successfully,it should not give wrong output.


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


-----------------------------------------------------------------------------
संकेत कोकणे
Post #1385905
Posted Monday, November 19, 2012 1:16 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 2:16 AM
Points: 2,840, Visits: 3,983
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
Post #1386196
Posted Monday, November 19, 2012 2:04 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:05 AM
Points: 1,058, Visits: 2,697
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
Post #1386218
Posted Monday, November 19, 2012 2:15 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 2:16 AM
Points: 2,840, Visits: 3,983
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
Post #1386231
Posted Monday, November 19, 2012 2:25 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:05 AM
Points: 1,058, Visits: 2,697
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
Post #1386240
Posted Monday, November 19, 2012 3:00 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 2:16 AM
Points: 2,840, Visits: 3,983
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
Post #1386252
Posted Monday, November 19, 2012 3:28 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:05 AM
Points: 1,058, Visits: 2,697
thanks, will check

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



Regards
Durai Nagarajan
Post #1386268
Posted Monday, November 19, 2012 3:34 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 2:16 AM
Points: 2,840, Visits: 3,983
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
Post #1386275
Posted Monday, November 19, 2012 3:35 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:05 AM
Points: 1,058, Visits: 2,697
No, for some empcode and date combination the output is right for some it is wrong.

Regards
Durai Nagarajan
Post #1386276
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse