Click here to Skip to main content
12,895,135 members (50,915 online)
Rate this:
Please Sign up or sign in to vote.
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:
ALTER FUNCTION [dbo].[fn_C_desig] 
(@id varchar(15))
RETURNS varchar(50)
    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

>Tabe2I(Id int not null, Name nvarchar not null, pending_status not null, ......)
ALTER PROCEDURE [dbo].[p_regpending]
    SELECT [NAME]+'--'+ISNULL([dbo].[fn_C_desig](refcode),'') AS [Name],Id FROM Table2I  WHERE pending_status ='P'
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 29-Nov-12 2:09am
Updated 29-Nov-12 6:37am
ryanb31 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?
Krunal R 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100