jeudi 5 mars 2015

Stored procedure returns different result than the query in sql server


Vote count:

0




I have a stored procedure which has code something like this,



if Exists(select * from sysobjects where name = 'tblProducts_Details' and xtype = 'U')
begin
Drop table tblProducts_Details
End

select * into tblProducts_Details from tblProducts

alter table tblProducts_Details add gcode varchar(50)

update a set a.gcode = b.gcode from tblProducts_Details a
inner join GroupID_GCode_Mapping b
on a.Company = b.Company

alter table tblProducts_Details add group_code int

update a set a.group_code = b.local_group_code from tblProducts_Details a
inner join Cache.dbo.Z_MAP_GroupID_CGCode_Mapping b
on a.gcode = b.gcode

alter table tblProducts_Details add groupname varchar(2000)

update a set a.groupname = g.name from tblProducts_Details a
inner join tblProductsGroup g
on a.group_code = g.group_id


When I execute the above query separately, it returns perfect result. But when I execute this stored procedure, sometimes it returns a different result set (some rows have different values than desired values).


I don't have any idea why.



asked 57 secs ago







Stored procedure returns different result than the query in sql server

Aucun commentaire:

Enregistrer un commentaire