Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-server-2005
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)
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, ......)
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 29-Nov-12 3:09am
Edited 29-Nov-12 7:37am
v4
Comments
ryanb31 at 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 at 29-Nov-12 8:16am
   
You have your answer.. try to find that.. :)
srdusad at 29-Nov-12 8:22am
   
@sathishyadhuv .. can u pls post the code written in function "fn_C_desig"

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,455
1 OriginalGriff 8,295
2 Peter Leow 4,839
3 Kornfeld Eliyahu Peter 3,210
4 Maciej Los 2,301


Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2015
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