Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I have a simple stored procedure in which i update some data in the sql table. I am not getting any error when i execute the procedure but the update query inside the procedure is not updating the value. Please find the procedure below.
SQL
CREATE PROCEDURE [dbo].[UpdateEmpdata]
	@EmpID VARCHAR(50) 
    	
AS
BEGIN
    SET NOCOUNT ON;
    
    DECLARE @Domain AS VARCHAR(255)
     
    SELECT TOP 1 @Domain = D.SubDomain
    FROM Employee E, Domain D
    WHERE E.EmployeeID=D.DomainID
    AND E.EmployeeID=@EmpID	
 
    UPDATE EmpData
    SET Domain =  @Domain
    WHERE EmployeeID= @EmpID                 
         
END
GO

When i run the procedure, it is not updating any Domain value. It is also not giving any error.
EXEC EmpData '21211111'

But when i run the query separately, it is working !!!!

SQL
DECLARE @Domain AS VARCHAR(255)
SELECT TOP 1 @Domain = D.SubDomain
    FROM Employee E, Domain D
    WHERE E.EmployeeID=D.DomainID
    AND E.EmployeeID='21211111'

    UPDATE EmpData
    SET Domain =  @Domain
    WHERE EmployeeID= @EmpID


That means there is no issues with the query.

But i am not understanding why the data is not updating while running through the procedure.

Please help.

Thanks in advance.
Posted
Comments
damodara naidu betha 17-Oct-12 3:08am    
Please provide tables schema and sample data, because we can't log in into your db :)

1 solution

check your procedure name used while executing store procedure.if i am not wrong it's "UpdateEmpdata"
not "EmpData"
EXEC EmpData '21211111'
so it should be
EXEC UpdateEmpdata '21211111'
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900