Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have one table named as TableC1 which contains
>TableC1(R_Id int, C_name varchar(50), C_type varchar(50), ......)
Function for this table:
SQL
ALTER FUNCTION [dbo].[fn_C_desig] 
(@id varchar(15))
RETURNS varchar(50)
AS BEGIN
    declare @name varchar(25)
    declare @desig varchar(50)
    select @name=Customer_name,@desig =Customer_type from tbl_ais_customer where reg_id=@id
    return @name +'-'+ @desig
END

>Tabe2I(Id int not null, Name nvarchar not null, pending_status not null, ......)
SQL
ALTER PROCEDURE [dbo].[p_regpending]
AS
BEGIN
    SET NOCOUNT ON;
    SELECT [NAME]+'--'+ISNULL([dbo].[fn_C_desig](refcode),'') AS [Name],Id FROM Table2I  WHERE pending_status ='P'
END
But i got this error
"Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'admin1234' to data type int.
"


Please help me some one.
Posted
Updated 29-Nov-12 6:37am
v4
Comments
ZurdoDev 29-Nov-12 8:13am    
It appears that somewhere you need to convert to a string because it thinks something should be an int. I don't see where the issue is but that is what the error is telling you. What does the SQL look like where you are calling this?
[no name] 29-Nov-12 8:16am    
You have your answer.. try to find that.. :)
srdusad 29-Nov-12 8:22am    
@sathishyadhuv .. can u pls post the code written in function "fn_C_desig"

1 solution

The error message is pretty clear. Some of the column is expecting integer value but you are supplying a string/varchar. Now to find where the error is run the query in a query analyzer and double click the error message and it will show you the line where the error exactly is.
 
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