Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
when i execute my store procedure:

PROCEDURE [dbo].[GetEmailAdd_Sp]
    @emplid int
    AS
BEGIN
    Declare @emplEmail varchar(50)

    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    Set @emplEmail = (Select emailAdd from HrEmployee where EmplID = @emplid)
    return @emplEmail

END

then it throws error when i execute:
C#
Conversion failed when converting the varchar value '[SomeEmailID]' to data type int.
Exec

SQL
Exec GetEmailAdd_Sp 5
Posted
v2
Comments
Hunain Hafeez 21-Feb-14 1:37am    
anybody ?
What is the DataType of EmplID Column?
Tom Marvolo Riddle 21-Feb-14 1:38am    
you cannot convert varchar value to int.check the records in table

RETURN only allows you to return an integer value: you cannot return a string.
You need to use SELECT, or create an OUTPUT parameter.
 
Share this answer
 
Comments
King Fisher 21-Feb-14 2:12am    
you are right.My +5 sir
You have to change the type of your parameter into int:
SQL
Declare @emplEmail int
 
Share this answer
 
v2
just run it

SQL
PROCEDURE [dbo].[GetEmailAdd_Sp]
    @emplid int
    AS
BEGIN
    Declare @emplEmail varchar(50)

    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    Set @emplEmail = (Select emailAdd from HrEmployee where EmplID = @emplid)
    return @emplEmail

END



Exec GetEmailAdd_Sp @emplid= 5
 
Share this answer
 

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



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